I’m running docker on Rockylinux 8.5 (successor of CentOS).
I’m also running PiHole (Ad-Blocker/DNS-Server) in a container with this docker-compose.yml
version: "3"
services:
pihole:
container_name: pihole
image: pihole/pihole:latest
restart: always
network_mode: host
environment:
WEBPASSWORD: 'top$ecret!'
PIHOLE_DNS_: '192.168.1.1'
WEB_PORT: 3080
INTERFACE: 'eno1'
DNS_BOGUS_PRIV: 'true'
DNS_FQDN_REQUIRED: 'true'
REV_SERVER: 'true'
REV_SERVER_DOMAIN: 'fritz.box'
REV_SERVER_TARGET: '192.168.1.1'
REV_SERVER_CIDR: '192.168.1.0/24'
# Volumes store your data between container upgrades
volumes:
- './etc-pihole/:/etc/pihole/'
- './etc-dnsmasq.d/:/etc/dnsmasq.d/'
In my AVM Fritz.box I set the IP of the docker-host as DNS-Server in DHCP settings.
I can see all lookups from my phones, PCs, … in pihole - even the lookups from my docker-host (e.g. nslookup foobar)
But all other containers can not lookup any ip.
docker run --rm -it alpine ping google.de
ping: bad address 'google.de'
even if i set the ip of my docker-host as dns it didn’t work
docker run --dns 192.168.1.111 --rm -it alpine ping google.de
ping: bad address 'google.de'
only if I set the IP of my router as DNS (which is also the only upstream dns for pihole) it works
docker run --dns 192.168.1.1 --rm -it alpine ping -c 5 google.de
PING google.de (142.250.185.195): 56 data bytes
64 bytes from 142.250.185.195: seq=0 ttl=116 time=27.413 ms
64 bytes from 142.250.185.195: seq=1 ttl=116 time=24.173 ms
64 bytes from 142.250.185.195: seq=2 ttl=116 time=21.969 ms
64 bytes from 142.250.185.195: seq=3 ttl=116 time=31.919 ms
64 bytes from 142.250.185.195: seq=4 ttl=116 time=23.535 ms
--- google.de ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 21.969/25.801/31.919 ms
So I think this has something to do with the docker-networking even if I use network_mode: host but I have no idea what to do that all containers can use the PiHole-Container as DNS.