I\'ve been trying to run Docker build on various files which previously worked before, which are now no longer working.
As soon as the Docker file included any line
I believe that Matt Carrier's answer is the correct solution for this problem. However, after implementing it, I still observed the same behavior: could not resolve 'archive.ubuntu.com'
.
This led me to eventually find that the network I was connected to was blocking public DNS. The solution to this problem was to configure my Docker container to use the same name server that my host (the machine from which I was running Docker) was using.
How I triaged:
docker run -it docker/whalesay bash
ping 172.217.4.238
(google.com)ping google.com
In my case, the first ping
resulted in responses, the second did not.
How I fixed:
Once I discovered that DNS was not working inside the container, I verified that I could duplicate the same behavior on the host. nslookup google.com
resolved just fine on the host. But, nslookup google.com 8.8.8.8
or nsloookup google.com 8.8.4.4
timed out.
Next, I found the name server(s) that my host was using by running nm-tool
(on Ubuntu 14.04). In the vein of fast feedback, I started up the example image again, and added the IP address of the name server to the container's resolv.conf file: sudo vi /etc/resolv.conf
. Once saved, I attempted the ping again (ping google.com
) and this time it worked!
Please note that the changes made to the container's resolv.conf are not persistent and will be lost across container restarts. In my case, the more appropriate solution was to add the IP address of my network's name server to the host's /etc/default/docker
file.