Skip to content

resolvconf.conf needs modification so local Docker containers get DNS #8

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

Closed
geerlingguy opened this issue May 19, 2021 · 11 comments
Closed
Labels
bug Something isn't working planned

Comments

@geerlingguy
Copy link
Owner

Over in geerlingguy/internet-monitoring#12 I was scratching my head over some new DNS issues with monitoring containers not being able to resolve DNS names—it caused Grafana to fail to launch, and all pings (once I figured out a way to get Grafana happy again) to fail.

As it turns out, Docker's built-in resolver at 127.0.0.11 was hitting the wrong backend for some reason since the Pi was getting it's LAN IP in /etc/resolv.conf.

So the fix was to uncomment the line:

name_servers=127.0.0.1

Inside /etc/resolvconf.conf.

It's probably important enough a change for compatibility that I should add a bit to the Ansible playbook to update that line in the file using lineinfile.

@geerlingguy
Copy link
Owner Author

Also—to immediately regenerate the file you can run sudo resolvconf -u (this could be a handler in the playbook maybe, triggered if the file is changed).

@Squelch
Copy link

Squelch commented Jul 7, 2021

Another symptom seems to be "DNS temporarily unavailable" when attempting to update gravity from the Pi-Hole GUI. Changing /etc/resolve.conf in the container from 127.0.0.11 to 127.0.0.1 seemed to fix it.

@Robin-Sch
Copy link

Robin-Sch commented Sep 16, 2021

I'm running only the internet monitoring part, and with the uptime domain checker thingy I get this error too. Sometimes it does work, and sometimes it fetches with this error (and then the domain gets a red bar).

Logs for the probe:
ts=2021-09-16T18:03:59.176311679Z caller=main.go:320 module=http_2xx target=https://mydomain.com/ level=info msg="Beginning probe" probe=http timeout_seconds=9.5
ts=2021-09-16T18:03:59.176499841Z caller=http.go:335 module=http_2xx target=https://mydomain.com/ level=info msg="Resolving target address" ip_protocol=ip4
ts=2021-09-16T18:03:59.178395177Z caller=http.go:335 module=http_2xx target=https://mydomain.com/ level=info msg="Resolved target address" ip=yes
ts=2021-09-16T18:03:59.178497458Z caller=client.go:251 module=http_2xx target=https://mydomain.com/ level=info msg="Making HTTP request" url=https://yes host=mydomain.com
ts=2021-09-16T18:04:08.678848323Z caller=main.go:130 module=http_2xx target=https://mydomain.com/ level=error msg="Error for HTTP request" err="Get \"https://yes/\": context deadline exceeded"
ts=2021-09-16T18:04:08.678926164Z caller=main.go:130 module=http_2xx target=https://mydomain.com/ level=info msg="Response timings for roundtrip" roundtrip=0 start=2021-09-16T18:03:59.178579739Z dnsDone=2021-09-16T18:03:59.178579739Z connectDone=2021-09-16T18:03:59.180154713Z gotConn=2021-09-16T18:03:59.189304472Z responseStart=0001-01-01T00:00:00Z tlsStart=2021-09-16T18:03:59.180208393Z tlsDone=2021-09-16T18:03:59.189160831Z end=0001-01-01T00:00:00Z
ts=2021-09-16T18:04:08.678966684Z caller=main.go:320 module=http_2xx target=https://mydomain.com/ level=error msg="Probe failed" duration_seconds=9.502600404

https://stackoverflow.com/questions/49817558/context-deadline-exceeded-prometheus
changing scrape timeout to 30 seconds fixed it

@ian-rose
Copy link
Contributor

Ran into this same issue... uncommenting name_servers=127.0.0.1 in Inside /etc/resolvconf.conf fixed the problem for me.

+1 to adding this change to the playbook

@HyperKiko
Copy link

HyperKiko commented Dec 12, 2021

how do i fix this if im running networkmanager and resolvconf isnt installed?

@jrwagz
Copy link

jrwagz commented Jan 7, 2022

+1 I had this same problem with the internet-pi setup, and was able to get it resolved by just uncommenting name_server=127.0.0.1 in /etc/resolvconf.conf and then rebooting. Maybe a reboot wasn't needed, but it didn't start working right away, so I just rebooted the pi to be sure.

@maxr2011
Copy link

maxr2011 commented Mar 3, 2022

why is this change not in the ansible repo?
Every time you provision a Pi you have to do this one by hand ...

@kretchy
Copy link

kretchy commented Apr 12, 2022

Guess this is related to this issue, but then it also somehow behaves differently.

Upon trying to get GRAFANA running, I get the restart loop as described by many others. Starting the docker-compose up -d --no-deps from ~/internet-monitoring it seems to create the front-tier network, but the container internet-monitoring_grafana_1 exits with the ERROR message, that the network {network-id} was not found:

ERROR: for internet-monitoring_grafana_1 Cannot start service grafana: network 153e8159ca612973863d2a43e4603c236481cade36b39129d1e57ab1ba1ce8e9 not found

The /etc/resolv.conf looks like this:

# Generated by resolvconf
nameserver 127.0.0.1

And the /etc/resolvconf.conf looks like this:

# Configuration for resolvconf(8)
# See resolvconf.conf(5) for details
resolv_conf=/etc/resolv.conf

# If you run a local name server, you should uncomment the below line and
# configure your subscribers configuration files below.
name_servers=127.0.0.1

# Mirror the Debian package defaults for the below resolvers
# so that resolvconf integrates seemlessly.
dnsmasq_resolv=/var/run/dnsmasq/resolv.conf
pdnsd_conf=/etc/pdnsd.conf
unbound_conf=/etc/unbound/unbound.conf.d/resolvconf_resolvers.conf

Finally I checked for the available networks with docker network ls and the {network-id} that internet-monitoring_front-tier seems to represent is not listed there.

Any ideas from you helpful and experienced docker-folks out there?

@kretchy
Copy link

kretchy commented Apr 13, 2022

Any ideas from you helpful and experienced docker-folks out there?

In fact #375 worked for me as a solution.

@N-Silbernagel
Copy link

N-Silbernagel commented Sep 19, 2024

For any future visitors: Found a solution for >= Bookworm (NetworkManager) on https://raspberrypi.stackexchange.com/questions/144937/how-to-use-public-dns-in-bookwork-64bit

That only helped, because docker used the default 8.8.8.8 dns in its /etc/resolv.conf. Real solution was https://stackoverflow.com/questions/64007727/docker-compose-internal-dns-server-127-0-0-11-connection-refused

@exkuretrol
Copy link

That only helped, because docker used the default 8.8.8.8 dns in its /etc/resolv.conf. Real solution was > https://stackoverflow.com/questions/64007727/docker-compose-internal-dns-server-127-0-0-11-connection-refused

Thanks! My Grafana container finally works properly. 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working planned
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants