Thursday, May 19, 2016

docker apt-get issues and DNS problems

I had trouble running a docker build because
apt-get update
apt-get -y install apache2 
won't work due to DNS resolution failures

Found these posts that explained why:

Quoting the solution:
Those Google servers weren't accessible from behind our firewall, which is why we couldn't resolve any URLs.
The fix is to tell Docker which DNS servers to use. This fix depends on how you installed Docker:
Ubuntu Package
If you have the Ubuntu package installed, edit /etc/default/docker and add the following line:
DOCKER_OPTS="--dns <your_dns_server_1> --dns <your_dns_server_2>"
You can add as many DNS servers as you want to this config. Once you've edited this file you'll want to restart your Docker service:
sudo service docker restart
If you've installed Docker via the binaries method (i.e. no package), then you set the DNS servers when you start the Docker daemon:
sudo docker -d -D --dns --dns &
And on a windows machine, you can run
ipconfig /all
to find your DNS servers
On a linux host (ubuntu 16.10) you can do
nmcli device show <device>

No comments: