-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Pi Hole Host Containers cannot resolve DNS internally #945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
There is a work around to fix this issue. if you shell into the docker container as root and do a nameserver 127.0.0.11 remove the extra 1 and then save and exit and do a |
Hey Devs looks like this issue is still around i have downloaded a fresh ne image and the resolv.conf still has the extra 1 in it. i know its an issue that has come up before |
See IOTstack issue 422 for the background to this. The basic trick is to define a default network with a fixed IP subnet so you can predict the IP address of the default gateway on that subnet. For example:
where the default gateway will be .1 on that subnet. It doesn't have to be that network and it doesn't have to be a /22. Just known and predictable so docker won't allocate a default network at random. All containers join a default network unless they have an explicit network definition of their own. If a container has an explicit definition AND you want it to use this method you also need to add a second explicit definition for it to join "default". Then, any container that needs to use PiHole for its DNS should have a For WireGuard, if you want remote clients to also use PiHole, set There might be similar "pass this in through an environment variable" considerations for other containers but you can see the general idea. I'm not really sure why this works. It just does. It's a bit smoother and more flexible than the alternative which is to set the host's /etc/resolvconf.conf to 127.0.0.1. If you do that, containers use 127.0.0.11 which means "follow the host's /etc/resolv.conf" but then things like WireGuard PEERDNS don't seem to work. Hope this helps. |
Well, that doesn't work if you have no name resolution inside the container. Something that works is: |
Whether that's the "correct" way or not depends, I think, on the Linux distro. In my experience the recommended approach is:
That causes |
@Paraphraser are you talking about the same issue? Neither did i say "this is the correct way", i only posted a feasible workaround that works inside the container, nor are your commands working inside the pihole container (no init system running). |
@Zeik0s my sincere apologies. I completely mis-read what you wrote. I thought you were talking about getting the whole system (host and containers) to use the PiHole container for DNS.
But getting back on topic, my PiHole service definition in
Running
Adding the Outside container-space, my Raspberry Pi's
Running
The "trick" mentioned earlier of using the default gateway on the internal bridged network provides a way of telling other containers to use PiHole for DNS, assuming that setting the host's I don't pretend to understand the how or why of most of this. The behaviour is just what I've observed as I kick the tyres. And, again, my apologies for not reading more carefully. |
@Paraphraser don't worry, mistakes happen, i was just confused. 😄 |
This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days. |
I haven't checked if this has changed with the last two updates of the docker image. Will retry later.
Sent from Nine
…________________________________
Von: "github-actions[bot]" ***@***.***>
Gesendet: Samstag, 8. Jänner 2022 18:18
An: pi-hole/docker-pi-hole
Cc: Zeik0s; Mention
Betreff: Re: [pi-hole/docker-pi-hole] Pi Hole Host Containers cannot resolve DNS internally (Issue #945)
This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
I've found this issue today and I fixed it by removing the extra
It would be nice to have this fixed on the docker image itself. |
127.0.0.11 is set by docker itself, that's the docker nameserver that is used so containers can communicate via names instead of IP addresses. |
If you're using a user defined docker network you're stuck with docker handling container DNS requests with its internal resolver on 127.0.0.11, which then forwards to the host. If you use the default bridge network your containers will inherit the host's /etc/resolv.conf instead. Documentation here. |
Well, that part is a bit tricky.
|
I am also experiencing this issue. I have been troubleshooting this for a few days. https://www.reddit.com/r/homelab/comments/sknit5/docker_containers_cannot_resolve_dns/ |
On my Ubuntu-server I resolved that issue by adding 127.0.0.1 as DNS to /etc/resolv.conf on the host-machine.
My /etc/resolv.conf looks like that now:
I'm not sure if it's the best way, but like that I don't have to change my docker-networks or adjust my /etc/resolv.conf inside the PiHole container. |
This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days. |
Uh oh!
There was an error while loading. Please reload this page.
This is a: Bug
Details
I am running Pi Hole as a Docker Container, using
docker-compose
on a Debian 11 host. DNS resolution works great on the host, and on all devices using it across my LAN. However, the Pi Hole container itself, and other containers on the same host cannot themselves resolve any DNS queries (such as when updating Gravity via the GUI).I am not currently sure whether the issue lies with the Debian host, Docker itself or with the containers, hence I will raise an issue here first and work backwards.
Inside a container does not resolve DNS (i.e.
ping pi-hole.net
) and returnsping: bad address 'pi-hole.net'
. Pinging any internal or external IP works without issue. Pinging pi-hole.net on the host works fine.Related Issues
How to reproduce the issue
services:
pihole:
image: pihole/pihole:latest
container_name: pihole
volumes:
- /storage/pihole/etc-pihole:/etc/pihole
- /storage/pihole/etc-dnsmasq.d:/etc/dnsmasq.d
environment:
- 'Europe/London'
ports:
- "53:53/tcp"
- "53:53/udp"
- "67:67/udp"
- "80:80/tcp"
restart: always
These common fixes didn't work for my issue
docker run
example(s) in the readme (removing any customizations I added)If the above debugging / fixes revealed any new information note it here.
Add any other debugging steps you've taken or theories on root cause that may help.
The text was updated successfully, but these errors were encountered: