-
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
docker containers cannot access consul DNS out of the box (not sure if bug or feature request) #12894
Comments
@josh-m-sharpe, The solution boils down to setting consul dns at a private IP instead of 127.0.0.1. Coming soon in Nomad 1.3 is support for variable interpolation of the network.dns values (well it currently doesn't work, but I've got a PR up to fix it). This means that if you set consul to use 0.0.0.0, you can then set the dns to attr.unique.network.ip-address. You may still need to ensure that consul dns is available on port 53, but that's the solution we're going to attempt once Nomad 1.3 is released. |
@josh-m-sharpe If your host machine already resolves I have a similar setup using DNSMasq: file: /etc/dnsmasq.d/10-consul
The following line is APPENDED to /etc/dhcp/dhclient.conf
and my Nomad Docker jobs have this:
|
Did these (very helpful) posts from the community help you get to a working configuration? thx @shantanugadgil && @twunderlich-grapl !!! |
I'm in the same boat, running Nomad 1.3.1. DNS works on the host (after following https://learn.hashicorp.com/tutorials/consul/dns-forwarding#systemd-resolved-setup) and not in containers. This runs counter to https://www.nomadproject.io/docs/job-specification/network#dns:
Also relevant: https://github.com/docker/docker-ce/blob/master/components/engine/libnetwork/resolvconf/resolvconf.go#L35-L39:
Regarding Nomad 1.3:
I''ll try this shortly, it should work as an interim solution. However, this involves: This feels pretty clunky and error-prone. Are there other ways to insert Consul DNS lookups into Docker's DNS resolution? For example, running DNS on the Docker bridge IP (which is used by containers to find each other on non-default bridges)? Nomad + Consul + Docker tasks is the most common use case, ideally this would Just Work! |
FYI, the PR I mentioned was #12817, presumably it'll actually be released as part of 1.4.0 but 🤷 |
Chewing on this a bit, docker containers are already routable to the host's private interfaces, and we do have a way to insert ourselves onto that path, iptables! I haven't found the right invocation yet. This doesn't work:
|
@pikeas does this not help? |
I ended up swapping out systemd-resolved for CoreDNS and it's been working well so far. I also realized that Consul Connect is a better solution for 90% of my needs, as it provides for inter-service routing. |
My current solution is to setup systemd-resolved (version 247+) as described in the tutorial, configure a extra stub listener for the default Docker bridge interface, e.g. docker0 and configure the docker daemon to use the bridge interface ip as dns server. /etc/systemd/resolved.conf.d/docker.conf [Resolve]
DNSStubListener=yes
DNSStubListenerExtra=172.17.0.1 /etc/docker/daemon.json {
"dns": ["172.17.0.1"]
} I've described this approach with a bit more detail here |
no it didn't work for me |
Is this issue similar to my issue? https://discuss.hashicorp.com/t/consul-agent-not-resolving-inside-ubuntu-docker-container/51106 |
Following #12894 (comment) answer, If you guys are using google cloud,
From your docker container, |
Nomad version
1.2.3
Operating system and Environment details
nomad / consul / amazonlinux2
consul DNS works on the host machine seemingly a-ok. Both of these work:
...but they do not work inside any docker container - which includes nomad docker managed containers.
Reproduce:
On a nomad client (with nomad/consul agent running)
Issue
nomad docs (https://www.nomadproject.io/docs/job-specification/network#dns) read:
Sets the DNS configuration for the allocations. By default all DNS configuration is inherited from the client host.
-- but this doesn't seem to apply to docker containers.It does also say:
DNS configuration is only supported on Linux clients at this time.
- does this mean not "docker clients" ?Is this documentation wrong or should maybe include an asterisk for docker?
If it isn't possible out of the box - what changes can I make to allow docker containers to access their host DNS?
The text was updated successfully, but these errors were encountered: