Fix docker network build issues
When running a docker build after the docker daemon is updated, the build logs keep failing with:
Could not connect to archive.ubuntu.com:80 (185.125.190.36), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to archive.ubuntu.com:80 (185.125.190.39), connection timed out
...
It turns out that the docker daemon is unable to use the host networking to do a apt-get update
within the ubuntu container during the build process and as such is unable to call out to the remote host.
To fix the issue system wide we can create a /etc/docker/daemons.json
file with the right naemserver entries and restart the docker daemon:
Firstly, run the following to get the host DNS server ip
Create a file at /etc/docker/daemons.json
with the following entries:
Restart the docker daemon
As a test we can run the following image to see if it can do a nslookup of google.com from within a container:
The response should include the DNS server address from above:
Hope it helps someone!