Docker container IP address / address not matching up

Please follow the below template, it will help us to help you!

If you are Experiencing issues with a Pi-hole install that has non-standard elements (e.g you are using nginx instead of lighttpd, or there is some other aspect of your install that is customised) - please use the Community Help category.

Expected Behaviour:

Apologies for any bad formatting, I've never posted here before, and couldn't find a formatting guide.

Operating System: Raspbian GNU/Linux 9 (stretch) [DietPi flavor]
Hardware: Raspberry Pi 3 Model B
Docker Version: Docker version 19.03.12, build 48a66213fe
Docker Image: Official (pihole/pihole:latest)
Docker Command:

docker run -d --name pihole -p 53:53/tcp -p 53:53/udp -p 80:80 -p 443:443 -e TZ="America/New_York" -v pihole:/etc/pihole/ -v dnsmasq:/etc/dnsmasq.d/ --dns=127.0.0.1 --dns=1.1.1.1 --restart=unless-stopped --hostname pi.hole -e VIRTUAL_HOST="pi.hole" -e PROXY_LOCATION="pi.hole" -e SERVERIP="192.168.1.2" -e WEBPASSWORD="[redacted]" pihole/pihole:latest

My pihole is only accessible via http://192.168.1.2/ -- not via the address http://pi.hole/

The /etc/hosts file in the container shows that the address pi.hole points to the docker bridge IP of 172.17.0.2. When I try to go to the pi.hole address on my desktop's browser, it (unsuccesfully) directs me to the 172.17.0.2 IP address. I'm unable to edit the hosts file, to try and change that line. Adding a local record to point to the correct IP in the pihole web interface does not override the hosts file.

root@pi:/etc# stat hosts
  File: hosts
  Size: 172             Blocks: 8          IO Block: 4096   regular file
Device: b302h/45826d    Inode: 126861      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2020-08-19 08:37:21.172217861 -0400
Modify: 2020-08-19 08:37:21.182217661 -0400
Change: 2020-08-19 08:37:21.642208476 -0400
 Birth: -

root@pi:/etc# mv hosts hosts.old
mv: cannot move 'hosts' to 'hosts.old': Device or resource busy

root@pi:/etc# sed "s/172.17.0.2/192.168.1.2/" hosts -i
sed: cannot rename ./sednLKIhD: Device or resource busy
root@pi:/etc#

Doing a dig for pi.hole from another device:

[goose@vergil: ~ ] $ dig pi.hole
; <<>> DiG 9.11.5-P4-5.1+deb10u1-Debian <<>> pi.hole
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20561
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;pi.hole.                       IN      A

;; ANSWER SECTION:
pi.hole.                2       IN      A       172.17.0.2

;; Query time: 1 msec
;; SERVER: 192.168.1.2#53(192.168.1.2)
;; WHEN: Wed Aug 19 10:04:50 EDT 2020
;; MSG SIZE  rcvd: 52

[goose@vergil: ~ ] $

Debug Token:

https://tricorder.pi-hole.net/2wv4b7ggn2

For anyone else who comes across this, adding the flag --network host to my docker command fixed it.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.