Moby: resolv.conf no such file o directory

Created on 26 Mar 2014  ·  17Comments  ·  Source: moby/moby

i just left to install docker on ubuntu 12.04 from this guide :
http://docs.docker.io/en/latest/installation/ubuntulinux/
and i got this

➜ ~ sudo docker run -i -t ubuntu /bin/bash
2014/03/26 11:45:17 Error: open /etc/resolv.conf: no such file or directory

any suggestions?

arenetworking kinbug

Most helpful comment

I experience this issue and it seems to be a side-effect of the NetworkManager config on my distribution, Sabayon Linux.

In my case, /etc/resolv.conf is a symlink to /etc/resolvconf/run/resolve.conf and is only created after NetworkManager connects to a network. This makes Docker fail to start on boot but it starts fine after I've logged in and connect to a network.

All 17 comments

Problem with your host machine. Create /etc/resolv.conf and populate it with appropriate DNS information and try the command again.

This isn't a Docker bug, it's a problem caused by the absence of /etc/resolv.conf on your host. I can reproduce the problem when there's no resolv.conf on the host.

Please fix your Linux system.

IMHO the file is not necessary, is it? So, it shouldn't be about a broken OS.
http://man7.org/linux/man-pages/man5/resolv.conf.5.html

If this file does not exist, only the name server on the local machine will be queried;

In that case DNS server should be running on your local machine.

I experience this issue and it seems to be a side-effect of the NetworkManager config on my distribution, Sabayon Linux.

In my case, /etc/resolv.conf is a symlink to /etc/resolvconf/run/resolve.conf and is only created after NetworkManager connects to a network. This makes Docker fail to start on boot but it starts fine after I've logged in and connect to a network.

@OOPMan In your init script shouldn't you depend on NetworkManager being up before the docker service is started?

I also wonder if this should be an upstream Go (specifically "netgo") issue - do we actually check for resolv.conf directly, or only indirectly via the netgo implementation?

I've realised that my problem has nothing to do with NM or Sabayon Linux :-)

I am running on an Asus X550CC. Overall, a decent machine but it has one caveat: The Wi-Fi hardware is disabled under Linux until you sleep and then resume. This means that on boot, unconnected to a wired LAN, the system basically decides there is no working network and hence /etc/resolv.conf doesn't contain anything. Docker doesn't like this and hence fails to start.

Once I've suspend-resumed then everything is fine and Docker starts.

@unclejack @crosbymichael I am still seeing this issue today on docker version 1.12.6.
Why does /etc/resolv.conf gate running docker containers?

I think there hasn't been a good answer on this and since I'm also experiencing this I'm reopening. @thaJeztah could you ping network maintainers? At this point I don't understand why container start is gated by network (we do have isolated machines where there's no resolv.conf file but we want to start containers anyway)

The resolv.conf manual (from glibc) states:

   If this file does not exist, only the name server on the local
   machine will be queried; the domain name is determined from the
   hostname and the domain search path is constructed from the domain
   name.

Therefore it should be assumed that a Linux system without a resolv.conf is a valid Linux system.

Other software such as golang's DNS resolv.conf loading logic, deals with missing or inaccessible resolv.conf in the same way: https://golang.org/src/net/dnsconfig_unix.go

Also, resolv.conf is not necessary on systems which use non-libc NSS modules such as nss-resolve or winbind, ldap, etc.

/cc @sanimej

This bug also prevent from using docker offline on some distributions.

just create an empty file names 'resolv.conf' at the place, my problem solved~

I see the fix for this was merged through https://github.com/moby/moby/commit/1ddeb11835600127a3319fc0dd3764e57ffbf521, which will be included in the upcoming 17.10 release; https://github.com/docker/docker-ce/blob/17.10/components/engine/vendor/github.com/docker/libnetwork/sandbox_dns_unix.go

closing, because this is resolved on master 👍

Was this page helpful?
0 / 5 - 0 ratings