docker network conflict?
Docker uses 172.17.0.0 as the first network and increments the second octet for each new network. If your network happens to use internal networks in the range, you'll have routing problems. Here's how to change what docker uses for numbering networks.
Docker uses daemon.json
which is usually in /etc/docker
if you install it as a package. If you install docker as a snap, which is recommended, you'll find it in /var/snap/docker/current/config/daemon.json
. Here's an example of the change to make:
{
"log-level": "error",
"storage-driver": "overlay2",
"default-address-pools":
[
{"base":"172.100.0.0/16","size":24}
]
}
Add the "default-address-pools" key and the associated value, change the network base to suit your needs. Remember to add a ,
to the end of the prior line.
The base will be the first network, successive networks will increment from there. I've been unable to find clear documentation on the base value string, but my intuition is that the /16
means each new network provisioned will increment at the 2nd octet, in this case 172.100, 172.101, 172.102, and so on. However, the size, i.e. netmask, will be a /24
. It's not clear why the network stepping and size are not the same.
If you're using snaps, to reload the configuration means restarting the daemon:
sudo snap restart docker
If it doesn't restart, you can see the logs:
sudo snap logs docker
To see that the change worked, take a look at the bridge, default, network:
$ docker network inspect bridge
[
{
"Name": "bridge",
"Id": "c96d8c88432e1120cf0260677f503eb1d2e04c692f81d2e9a034115384e8a763",
"Created": "2021-01-29T07:36:04.76114402-05:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.100.0.0/24"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
]