I am running three docker apps, one of them in PiHole. This is my docker-compose.yml
version: "3"
services:
pihole:
container_name: pihole
image: pihole/pihole:latest
ports:
- "10.10.6.1:53:53/tcp"
- "10.10.6.1:53:53/udp"
- "10.10.6.1:67:67/udp"
- "10.10.6.1:8080:80/tcp"
environment:
TZ: 'Europe/Ljubljana' #this is the time zone
volumes:
- './etc-pihole/:/etc/pihole/'
- './etc-dnsmasq.d/:/etc/dnsmasq.d/'
dns:
- 127.0.0.1
- 1.1.1.1
cap_add:
- NET_ADMIN
restart: unless-stopped
extra_hosts:
- "host.docker.internal:host-gateway"
If I go to docker exec -it 0415002e9e7d /bin/bash
, I can ping host.docker.internal
:
PING host.docker.internal (172.17.0.1) 56(84) bytes of data.
64 bytes from host.docker.internal (172.17.0.1): icmp_seq=1 ttl=64 time=0.188 ms
64 bytes from host.docker.internal (172.17.0.1): icmp_seq=2 ttl=64 time=0.146 ms
Now. On a host machine I installed Unbound DNS server. It is running on a port 5335
. This is the command from the host machine: dig dnssec.works @localhost -p 5335
...
;; ANSWER SECTION:
dnssec.works. 2387 IN A 5.45.107.88
;; Query time: 0 msec
;; SERVER: 127.0.0.1#5335(127.0.0.1)
...
DNS server querying from the host machine works just fine!
However, if I go to docker exec -it 0415002e9e7d /bin/bash
and run the command dig dnssec.works @host.docker.internal -p 5335
, I get connection timed out; no servers could be reached.
So obviously I can not connect from docker to the host machine. Any idea how to solve this?
P. S.
Unbound DNS server config contains this:
access-control: 127.0.0.0/8 allow
access-control: 172.17.0.0/24 allow
So I am allowing connections from localhost and from docker internal network, but it is still not working…