By default, the docker0
interface should have the ip 172.17.0.1 and use the subnet 172.17.0.1/16
With vanilla docker, you can configure the default bridge ip in /etc/docker/daemon.json
like this:
"bip": "172.17.0.1/24",
"default-address-pools": [
{
"base": "172.30.0.0/16",
"size": 24
},
{
"base": "172.31.0.0/16",
"size": 24
}
],
bip
defines the ip of the docker0
interface and the subnet cidr it uses. You will need to stop Docker and delete the docker0
interface, in order to be re-created after restarting Docker (a reboot should do it as well).
The default-address-pools
are the subnet pools used for user defined networks, if they are created without specifying the subnet during creation. Docker needs to be restarted in order to use the modified settings. The base will define the broader cidr range pool, while size defines the subnet bits used for created networks (24 = 256 ips, is the default value).
Note: existing docker bridge networks will continue to use their cidr ranges. The easiest fix is to docker compose down
so the network gets removed as well, and will be re-created based on the default-address-pool settings.
You can run this command to identify which docker network uses conflicting ranges:
docker inspect --format '{{.Name}}:{{(index .IPAM.Config 0).Subnet}}' $(docker network ls -q)
Note: rendering the output of host
and none
networks will raise errors. For the sake of a simpler command, I didn’t add logic to the format expression to prevent it.