Cannot access web UI via pi.hole - but IP address works

Expected Behavior
Web interface is available at http://pi.hole/admin

Actual Behavior
Browsers/curl/ping time out on pi.hole/admin, but can reach the web interface via the IP address.

Debug Token
https://tricorder.pi-hole.net/xryo4iobnb

Setup

  • Raspberry Pi 4 Model B - 2GB DDR4 running Raspberry Pi OS May 2020
  • Pihole installed via Docker
  • ufw running on the host machine, allowing DNS and HTTP requests only from the LAN
  • Using Pihole only as DNS server, not for DHCP
  • Setting the pihole as my DNS server on a per-client basis, not at the router level

Debugging So Far

  • The host machine has IP 192.168.1.225
  • My computer has this IP as its DNS server
  • http://192.168.1.225/admin displays the web ui
  • http://pi.hole/admin times out
  • Using nslookup from my computer shows pi.hole resolves to the IP of the container, not the host machine
$ nslookup pi.hole
Server:		192.168.1.225
Address:	192.168.1.225#53

Name:	pi.hole
Address: 172.17.0.2
  • The IP of the container is not reachable from my computer:
$ ping 172.17.0.2
PING 172.17.0.2 (172.17.0.2): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
^C
--- 172.17.0.2 ping statistics ---
3 packets transmitted, 0 packets received, 100.0% packet loss

My Docker Command (slightly modified from docker-pi-hole/docker_run.sh at c619303a3096075858bcd684cdc2833da02dd2e1 · pi-hole/docker-pi-hole · GitHub)

docker run -d \
    --name pihole \
    -p 53:53/tcp -p 53:53/udp \
    -p 67:67/udp \
    -p 80:80 \
    -p 443:443 \
    -v "$(pwd)/etc-pihole/:/etc/pihole/" \
    -v "$(pwd)/etc-dnsmasq.d/:/etc/dnsmasq.d/" \
    --dns=127.0.0.1 --dns=1.1.1.1 \
    --cap-add=NET_ADMIN \
    --restart=unless-stopped \
    --hostname pi.hole \
    -e VIRTUAL_HOST="pi.hole" \
    -e PROXY_LOCATION="pi.hole" \
    -e TZ="America/New_York" \
    -e WEBPASSWORD="notactuallymypassword" \
    -e ServerIP="192.168.1.225" \
    pihole/pihole:latest

I'm not sure if there's something missing in my docker configuration or what, but it seems like it's not routing the http traffic to the container. Any help is appreciated!

Seems like you are running your dockered Pi-hole with a (probably default) bridge network configuration that isolates your container into a separate network.

You want to familiarise yourself with Docker's network modes. Once you get a better understanding, you should then decide on the network mode that best suites your need.

For a start, you could run your Pi-hole container in host mode, giving up on isolation, and use the same network as the machine that Docker runs on. If you add additional services in other containers later, you may want to review this decision and again switch to another isolating mode.

For configuration hints with regards to your Pi-hole, have a read of Pi-hole's documentation for Running Pi-hole Docker.

Running in host networking mode fixed this, I am able to access via pi.hole now. Thanks for the assistance!