Docker container can reach DNS but not resolve hosts
Asked Answered
F

3

19

I'm having an interesting problem running docker containers: out of the blue, I'm not able to resolve DNS from within the container.

Here's a rundown:

  1. Nothing is resolving; apt-get, pip, one-off ping containers, etc. Running docker run -it --dns=8.8.8.8 ubuntu ping www.google.com results in ping: unknown host www.google.com both with and without the --dns flag.

  2. I can reach 8.8.8.8 both from inside and outside the containers. docker run -it ubuntu ping 8.8.8.8 works.

  3. I've configured the containers to use both 8.8.8.8, 8.8.8.4, and my local network DNS servers (in various permutations) both by editing /etc/sysconfig/docker to add DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.8.4" and by setting the --dns 8.8.8.8 flag on the containers at runtime. systemctl restart docker was run between each change.

  4. ip_forward is enabled. (see here)

  5. I've done a full reset as specified here.

I'm running Fedora 21, docker client version 1.5.0.

Any ideas? I'm at a complete loss as to what's preventing docker from accessing the Internet successfully.

Funeral answered 25/3, 2015 at 21:8 Comment(2)
Perhaps you should open an issue in the docker issue tracker; github.com/docker/docker/issues. When doing so, please include the relevant information as explained here github.com/docker/docker/blob/master/CONTRIBUTING.mdBelie
Same here with fedora 22.Carousel
M
5

They have fixed the issue in 1.8: https://github.com/docker/docker/issues/13381 Cheers.

Monafo answered 10/8, 2015 at 20:28 Comment(2)
Could you link to the fix for posterity?Funeral
Yeah, link was a pain to re-find lol. I really need to start tracking the Q&A of my problems for reference.Monafo
F
1

After all this, a full reboot solved the problem - although, that still doesn't answer what it was.

If anyone knows what the actual cause was, I'm still curious, but for now the problem is gone.

Funeral answered 29/3, 2015 at 16:26 Comment(1)
I'm having the problem repeatedly, reboot helps but can't be the solution. The problem doesn't just occur with the ubuntu image, but all I've tried.Carousel
U
0

You could install tools like dig inside the docker image to alanyse the issue.

use static hosts in your /etc/hosts file te make apt-get run inside the docker image. add these lines to your hosts file:

213.32.5.7 debian.mirrors.ovh.net
141.76.2.4 ftp.de.debian.org 
217.196.149.233 mirror-conova-security.debian.org
212.211.132.250 lobos.debian.org
212.211.132.250 security.debian.org 
5.153.231.4  http.debian.net 
151.101.12.204 cdn-fastly.deb.debian.org
151.101.12.204 security-cdn.debian.org
Uterine answered 10/11, 2018 at 13:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.