I try to run pi-hole via docker compose using Docker Desktop on Mac OS X. I managed to get it working as expected using the following docker-compose.yml
services:
pihole:
image: pihole/pihole:latest
ports:
- "53:53/tcp"
- "53:53/udp"
- "67:67/udp"
- "8082:80/tcp"
environment:
WEBPASSWORD: 'password'
volumes:
- './etc-pihole:/etc/pihole'
- './etc-dnsmasq.d:/etc/dnsmasq.d'
cap_add:
- NET_ADMIN
restart: unless-stopped
When I try to use the new network_mode: host, which is available since Docker Desktop 4.34 using a modified docker-compose.yml
services:
pihole:
image: pihole/pihole:latest
network_mode: host
environment:
WEBPASSWORD: 'password'
WEB_PORT: 8082
volumes:
- './etc-pihole:/etc/pihole'
- './etc-dnsmasq.d:/etc/dnsmasq.d'
cap_add:
- NET_ADMIN
restart: unless-stopped
the pi-hole container is still starting without any issues. However the filtering is not working anymore, although it still seems to receive the DNS queries. The ports 53 and 8082 in both cases are open and reachable. I looked at the start logs in both cases and the only differences between the first case using port forwarding and the second case using network_mode: host are
> [i] Custom WEB_PORT set to 8082
> [i] Without proper router DNAT forwarding to 0.0.0.0:8082, you may not get any blocked websites on ads
24c26
< "VIRTUAL_HOST" => "e5b5fb18ddd8",
---
> "VIRTUAL_HOST" => "docker-desktop",
What could be the reason why filtering doesn’t work in the second case? Can I fix my docker-compose.yml so that pi-hole also filters when using network_mode: host?