Docker Community Forums

Share and learn in the Docker community.

Docker container can’t use PiHole DNS Server in another container

Hi there,

I’m running Raspbian Release 10 (Kernel Linux 5.4.51-v7+) on a RPi Modell 3 with currently two Docker containers. The first container is the “pihole/pihole:latest” image which works just fine. PiHole runs with the IP address 192.168.178.67/24.

pi@myRPi:~ $ cat /etc/resolv.conf
'# Generated by resolvconf
domain fritz.box
nameserver 192.168.178.67

My router has the IP address 192.168.178.1 and works as a backup DNS server. When creating the second container I’m not able to connect to the internet, unless I add ‘–dns 192.168.178.1’ to the command line.

Ping to the backup DNS server

pi@myRPi:~ $ docker container exec e408c3722e1e ping -c 2 192.168.178.1
PING 192.168.178.1 (192.168.178.1) 56(84) bytes of data.
64 bytes from 192.168.178.1: icmp_seq=1 ttl=63 time=2.53 ms
64 bytes from 192.168.178.1: icmp_seq=2 ttl=63 time=4.81 ms

— 192.168.178.1 ping statistics —
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 2.536/3.675/4.814/1.139 ms

Ping to the PiHole

pi@myRPi:~ $ docker container exec e408c3722e1e ping -c 2 192.168.178.67
PING 192.168.178.67 (192.168.178.67) 56(84) bytes of data.
64 bytes from 192.168.178.67: icmp_seq=1 ttl=64 time=0.255 ms
64 bytes from 192.168.178.67: icmp_seq=2 ttl=64 time=0.254 ms

— 192.168.178.67 ping statistics —
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.254/0.254/0.255/0.015 ms

Both DNS servers are reachable from within the second container.

I’d like to use the PiHole instead of the backup DNS server for the second container, but I don’t know why this doesn’t work.

Any help appreciated.

Was able to fix it. Instead of using ‘–dns 192.168.178.1’ I just used the IP address from the PiHole Docker container ‘–dns 172.17.0.3’ which worked perfect.

I have the same events with the armhf. The workarounds ( pihole docker private ip 172… Or external dns server (ie my router dns)) .

I tried a “docker network connect pihole_default mycontainer”. I could ping on container’s name but not on external names.

Embedded dns may be a point to analyze. I did not find the latest version of that point (18.03)

Note: If you need access to a host’s localhost resolver, you must modify your DNS service on the host to listen on a non-localhost address that is reachable from within the container.

Note: The DNS server is always at 127.0.0.11.
I noticed that problem after an unwanted reboot last tuesday (07/17/18) :frowning: the container was created beginning of june. Raspberry Updates are installed as they re out.

The probleme seems to be because we are running containers on the same host that run pihole in a container.