Docker Can Only Create 31 Default Networks
I have just learned that Docker has a limit of 31 networks for a default
bridge network driver on a single machine:
~$ docker network create test1
~$ docker network create test2
~$ docker network create test31
~$ docker network create test32
Error response from daemon: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network
This is due to the fact that it uses a hardcoded list of broad network ranges for a
bridge network driver:
192.168.x.x/20. For an
overlay network driver, 64K networks can be created. If you want to know the implementation details, please look into Docker libnetwork’s ipamutils and allocator.
The only solution to circumvent this limitation seems to be manually specifying subnet ranges for each created network (please see Docker network create subnet option and Docker Compose network configuration reference):
docker network create --subnet=192.168.1.0/24 test1
In Puffin, which needs to create a separate network for each application, I implemented a simple address allocator.
Originally published at loomchild.net on September 4, 2016.