-
Notifications
You must be signed in to change notification settings - Fork 880
Ubuntu 18.04 + Docker 17.12.1-ce break DNS resolution #2187
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
@mprobst in case of standalone container, you are in control on which dns to use, if you don't specify anything you will get by default the google ones. if 8.8.8.8 does not work for you, you can specify others with |
@fcrisciani my host system has a If this is how Docker does and will behave, I guess this is an upstream bug in Ubuntu's package setup. |
@mprobst |
I agree there is an issue here somewhere... I have docker 18.03.0-ce running on Ubuntu 16.04 with custom DNS entries in /etc/resolv.conf, e.g.: Now on a new machine running docker 18.05.0-ce on Ubuntu 18.04 with the same DNS setup but configured with netplan (which is part of 18.04 changes). The /etc/resolv.conf file should not be edited by hand and uses systemd-resolved - it has an internal Clearly Ubuntu is different w.r.t. DNS in 18.04, but I haven't confirmed whether Docker is also behaving differently, or just defaults to Google DNS because it somehow knows that 127.0.0.53 is not going to work inside the container. My workaround for now is to use the --dns option when starting containers to manually specify the hosts, but I would rather the DNS inheritance from the host continued to work! Documentation ref: Related issue? |
Probably related moby/moby#36153 If it's worth something, I posted in SO with updated information https://stackoverflow.com/questions/51105875/internet-connection-not-working-networkmanager-not-working-after-installing-dock |
I really don't think this issue should have been closed- docker is broken out of the box on any corporate network, and in a non-obvious way that will usually require the hunting down of this issue in order to find a work around. Would it not be possible for docker to detect the presence of |
I also encountered the same issue after upgrading to Ubuntu 18.04. Although Docker has a --dns to explicitly set external DNS server, it is not a ideal way. |
I looked into this a bit deeper to add some color as to what is going on here. Docker spawns a resolver for all user-defined networks. From moby/moby:
and from libnetwork:
So for non-user-defined networks (e.g.
Running the same command without the Containers without resolver proxying have no way to reach the host's This is why @comdw saw the name server's being copied in, but others have not in ubuntu 18.04. A simple workaround if your system is unable to reach 8.8.8.8 / 8.8.4.4 (the defaults provided when no other host resolution seems possible) may well be to place your containers in a user-defined bridge network rather than the default Given how annoying this would be in general, the right solution would seem to be a change of policy (or an override) in moby to re-enable proxy resolution for the |
As this thread is referenced by Google, let me provide "how-to" on resolving the issue with the docker builds on Ubuntu 18.04.
|
We solved this by adding the following to every docker run command. Using this approach we at least didn't have to modify any system wide files on our file system.
The fact that we had to do this on all of our Ubuntu 18.04 servers is obnoxious. |
@mushkevych What OS are you using? in 18.04 there's no |
@diegoquintanav I am using Ubuntu 18.04 |
@mushkevych It didn't solve it for me, do you have perhaps |
Has anyone found a solution for docker-compose yet? I can do it for individual containers, but so far I'm looking at having to dynamically create the docker-compose.yml to set DNS on my dev machine. |
I followed @kaneg's approach:
According to the man page With this setup in place, name resolution inside containers works just fine for me. |
I definitely agree that this should be treated like a bug. The solution @kaneg suggests unfortunately doesn't work on my system (Ubuntu 18.04, Docker 18.06.0-ce). This is my output:
however the container still have the incorrect configuration when started with docker-compose. The only 'workaround' I've found is to manually append the contents of |
worked for me, you just have to be sure that the file "/etc/resolv.conf is generated by "resolvconf". |
Guys I tried all the solutions but unfortunatelly, none workd for me!. The best way for me is to force the container to use the same network as the host by using the parameter --network host Example: $ docker exec -it test bash With docker-compose.yml
Greetings from Colombia |
I believe it should be fixed in Docker CE 18.09, by PR moby/moby#37485 |
I still have the issue on 18.09.0, build 4d60db4. # using OpenDNS
dns:
- "208.67.222.222"
- "208.67.220.220" |
I have the same problem. Starting a plain image like |
@kaneg solution worked perfect I just had to restart docker daemon to take effect. |
Tried a few of the options above with no luck.
I'm using docker-compose with a user-defined bridge network setup in the following manner:
My particular container with the issue is added to all 3 networks. I added my tests here: https://superuser.com/questions/1411111/docker-dns-resolution-slow-for-http-calls-in-node-application-ipv6-bridge-netw From the above, I'm getting a 4 second timeout before being able to then get a response from a HTTP request. The resolution of the domain is causing issues and it specifically seems to be waiting for the ipv6 failure to happen before retuning a response. I do not have ipv6 enabled on my dev machine nor production server. Listening on port 53 is systemd-resolve still so I went the route of symlink fix as per comment #2187 (comment) but this did not change anything.
Since systemd-resolve is in use I could normally switch to dnsmasq I guess however I've seen that this can break custom bridge networks as documented in the first post here #2068 (comment)
Is there anything else I can try or any more info I can provide? |
On a sidenote, In my case my problem was related to conflicting addresses with the DNS server in my local network. The solution is explained in https://superuser.com/questions/1336567/installing-docker-ce-in-ubuntu-18-04-breaks-internet-connectivity-of-host |
Just a warning when I ran this command I ended up losing internet access for the whole machine. |
Try this. My system is ubuntu 18.04. Set DNS
Then,
Uncoment after reboot, I get
Hope this works to you. |
I've done some more investigation into my issue with debug mode and checking the journal.
Above I see a failure and then a retry which is accounting for 4 second delay. Current etc/resolv.conf on host:
Inside container:
Docker daemon:
I have since removed the 10.0.0.2 dns entry and I have rebuilt the containers after killing the daemon and restarting. However I still see the dns resolution going to the same address and failing before then trying google.
|
@ImTheDeveloper This sounds a lot like https://www.weave.works/blog/racy-conntrack-and-dns-lookup-timeouts |
@kaneg thanks buddy. It works like a charm. |
Stable fix for docker caused networking issues on Ubuntu 18.04 - fix found moby/libnetwork#2187
Thanks. It's work for me |
This might be a dupe of #1654 (which is closed - but then this is still happening). /CC @sanimej who's been looking at that last year.
The default installation of Docker on Ubuntu 18.04 is broken if Google DNS servers 8.8.8.8 and 8.8.4.4 are not reachable for some reason.
Out of the box Ubuntu runs
systemd
, which creates a nameserver running on localhost:Docker ignores the localhost nameserver:
Because on my network,
8.8.8.8
is not reachable for some reason (different bug), name lookups time out:For completeness sake, the symptom that lead me to find this is that when building a Go based image and running
go get
in a build step, I get aCould not resolve host: github.com
(took me a while to piece this one together...):The text was updated successfully, but these errors were encountered: