Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker container can reach DNS but not resolve hosts

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.

like image 908
DNelson Avatar asked Mar 25 '15 21:03

DNelson


People also ask

Do Docker containers use host DNS?

DNS services conf configuration file. Containers that use the default bridge network get a copy of this file, whereas containers that use a custom network use Docker's embedded DNS server, which forwards external DNS lookups to the DNS servers configured on the host.

What DNS does a Docker container use?

Docker containers take DNS IPs from the host machine, which is managed by systemd-resolve . Those IPs themselves are the cloud provider's DNS.

What does IP 0.0 0.0 mean Docker?

By default, Docker exposes container ports to the IP address 0.0. 0.0 (this matches any IP on the system). You can also tell Docker which IP to bind on. This could be either 127.0. 0.1 or a different IP address.


1 Answers

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

like image 115
Matthew Sprankle Avatar answered Sep 29 '22 01:09

Matthew Sprankle