Fixing Docker over VPN on Ubuntu 20.04

If you are having trouble getting your docker containers to connect to network resources over a VPN, try this.

Fixing Docker over VPN on Ubuntu 20.04

If you are having trouble getting your docker containers to connect to network resources over a VPN, try this:

Edit the file: /etc/docker/daemon.json. If the file doesn't exist, then create it.

Add the following to the json file:

{
	"dns": ["10.0.0.1","192.168.0.1","8.8.8.8"],
	"bip": "192.168.200.0/16"
}

The DNS entry is a list of DNS servers that will be used by your docker containers. They will each be tried until a working entry is found.

The BIP entry changes the default subnet of the docker0 network device. Sometimes, the subnet on your VPN might clash with the subnet docker uses by default. Adding a manual entry here will prevent that conflict.

After you save the file, be sure to restart docker:

sudo systemctl restart docker