My Docker container has no internet

I had an issue with my Docker containers building when I am connected to my work network, this post is mainly for my archival and future use.

The Fix

Check the contents of resolv.conf:

$ cat /etc/resolv.conf

If it includes a line like nameserver it means the containers are obtaining an incorrect names server. To fix this edit the NetworkManager.conf file:

$ sudo nano /etc/NetworkManager/NetworkManager.conf

And comment out the line with dns=dnsmasq; the file should look like this:



Finally, restart the network manager:

$ sudo systemctl restart network-manager

Test again the container:

$ docker run ubuntu:16.04 apt-get update
Get:1 xenial InRelease [247 kB]
Get:2 xenial-updates InRelease [102 kB]