-
Notifications
You must be signed in to change notification settings - Fork 2k
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
inconsistent behavior for /etc/resolv.conf with stub resolvers #11033
Comments
For a little bit more context on my setup specifically, I disabled So, this was fine. In pure docker world, I set the default DNS nameserver to the docker bridge IP, so it can reach out from the container over the bridge IP to talk to the host resolver. This depends on me binding now the CoreDNS listener to both 127.0.0.1 and the docker0 bridge IP so it can respond. Where this falls apart is using nomad's bridge mode now is a different IP. This is sorta fine, but nomad seems to lazily create the bridge network when it's first needed. So I can't reliably bind CoreDNS to the All in all, I ended up working around this by not using I don't know exactly what nomad can really do here, but having some sensible way to say "I want to resolve DNS with consul on the host" would be good. What really tripped me up is the very undocumented and unexpected behaviors of libnetwork and what docker was doing here. And just for context, here's the trivial CoreDNS config I'm using:
|
I can offer yet another option (docker daemon.json):
where the ip is the private IP of the server. My coredns configuration looks like this:
Imo that is kinda the best of both worlds. Docker gets a fixed DNS server and CoreDNS uses whatever was configured on the host. |
Thanks for the detailed report @tgross! Also thanks @mattrobenolt and @apollo13 for the additional context. We will investigate this further. |
While chatting with @mattrobenolt about exposing Consul DNS to a Nomad task, we ran into something unexpected where the behavior I described in #8343 (comment) doesn't hold in the case where the client is not using
systemd-resolved
. It turns out thatdockerd
(or more properlylibnetwork
) special-cases how it creates a/etc/resolv.conf
file for containers when it thinkssystemd-resolved
is in use. Seemoby/libnetwork/resolvconf/resolvconf.go#L18-L21
systemd-resolved
,docker
tasks get the host's (non-stub)resolv.conf
.systemd-resolved
,exec
tasks get the stubresolv.conf
pointing to127.0.0.53
.systemd-resolved
, bothdocker
andexec
tasks get the host'sresolv.conf
.network.dns
block, bothdocker
andexec
tasks get the Nomad-managedresolv.conf
generated byGenerateDNSMount
While the inconsistent behavior is the "fault" of the task driver engine, it makes configuring Consul DNS for tasks in a sensible way challenging and awfully host-specific.
Some proposals:
resolv.conf
? This would break backwards compatibility but would make it possible to point tasks to a Nomad-controlled IP; this could be the host's IP or a Consul IP for a stub resolver, etc.exec
task drivers do the same thing thatdocker
does with the stub resolver? (This is kind of gross and is annoyingly undocumented in Docker, too, as far as we can tell).Reproduction for the stub resolver behavior.
Using the Vagrant machine found at the root of this repo and running the following jobspec that has both a
docker
andexec
task sharing a network namespace:Docker jobspec
The
docker
driver gets the "real" resolver used by systemd-resolved and found at/run/systemd/resolve/resolv.conf
:But the
exec
driver gets the stub resolver from the host's/etc/resolv.conf
Now replace systemd-resolved's stub resolver with unbound:
Restart the VM and make sure the stub listener isn't what's linked to
/etc/resolv.conf
anymore:Now both of them get the
/etc/resolv.conf
file from the host:restore your Vagrant VM back to the previous state
Then reboot the VM.
The text was updated successfully, but these errors were encountered: