Configuring Docker to not use the range

Solution 1:

It is possible to redefine default range.

$ docker -v
Docker version 18.06.0-ce, build 0ffa825

Edit or create config file for docker daemon:

# nano /etc/docker/daemon.json

Add lines:


Restart dockerd:

# service docker restart

Check the result:

$ docker network create foo
$ docker network inspect foo | grep Subnet
                    "Subnet": ""

It works for docker-compose too. More info here (merged)

Solution 2:

There are three places docker will generate network subnets.

  • The default bridge
  • User generated bridge networks
  • Swarm mode generated overlay networks

For the default bridge (called "bridge"), you can specify BIP (I believe that's Bridge IP; make sure it's a host IP, not a network IP) in the daemon.json file. And for user generated bridge networks you can define a subnet pool to pick from (assuming the user does not manually specify a subnet). For these two, your /etc/docker/daemon.json would look like:

  "bip": "",

Each address pool setting above defines a CIDR range and size of subnets to be allocated from that range. So the above defines two class B ranges that are allocated as class C networks (/24). You do need at least 18.06 for the default address pools. You will need to reload the docker daemon for this change to apply (systemctl reload docker). And this change will only modify newly created user networks, so you'll need to stop containers and delete existing networks in the wrong range.

In 18.09, Docker added the ability to specify the address range for swarm mode generated overlay networks. This can only be done at the time of swarm creation right now, hopefully that will be updated in the future to allow docker swarm update to adjust these pools:

$ docker swarm init \
  --default-addr-pool \
  --default-addr-pool \
  --default-addr-pool-mask-length 24