Reputation: 53
I wonder if there is any way to affect default subnet size and pool of addresses used when creating network without any parameters.
Steps to reproduce a problem: 1) Get a fresh VM with Docker (Ubuntu 16.04, Docker 1.12.3 in my case) 2) attempt to create 50 networks:
for i in {1..50}; do docker network create net-$i; done
at some point you will start getting errors 3) see the results:
for i in $(docker network ls -q); do docker network inspect --format='{{.Name}} {{.IPAM.Config}}' $i; done
Output looks like:
net-1 [{172.18.0.0/16 172.18.0.1/16 map[]}]
net-2 [{172.19.0.0/16 172.19.0.1/16 map[]}]
net-3 [{172.20.0.0/16 172.20.0.1/16 map[]}]
net-4 [{172.21.0.0/16 172.21.0.1/16 map[]}]
net-5 [{172.22.0.0/16 172.22.0.1/16 map[]}]
net-6 [{172.23.0.0/16 172.23.0.1/16 map[]}]
net-7 [{172.24.0.0/16 172.24.0.1/16 map[]}]
net-8 [{172.25.0.0/16 172.25.0.1/16 map[]}]
net-9 [{172.26.0.0/16 172.26.0.1/16 map[]}]
net-10 [{172.27.0.0/16 172.27.0.1/16 map[]}]
net-11 [{172.28.0.0/16 172.28.0.1/16 map[]}]
net-12 [{172.29.0.0/16 172.29.0.1/16 map[]}]
net-13 [{172.30.0.0/16 172.30.0.1/16 map[]}]
net-14 [{172.31.0.0/16 172.31.0.1/16 map[]}]
net-15 [{192.168.0.0/20 192.168.0.1/20 map[]}]
net-16 [{192.168.16.0/20 192.168.16.1/20 map[]}]
net-17 [{192.168.32.0/20 192.168.32.1/20 map[]}]
net-18 [{192.168.48.0/20 192.168.48.1/20 map[]}]
net-19 [{192.168.64.0/20 192.168.64.1/20 map[]}]
net-20 [{192.168.80.0/20 192.168.80.1/20 map[]}]
net-21 [{192.168.96.0/20 192.168.96.1/20 map[]}]
net-22 [{192.168.112.0/20 192.168.112.1/20 map[]}]
net-23 [{192.168.128.0/20 192.168.128.1/20 map[]}]
net-24 [{192.168.144.0/20 192.168.144.1/20 map[]}]
net-25 [{192.168.160.0/20 192.168.160.1/20 map[]}]
net-26 [{192.168.176.0/20 192.168.176.1/20 map[]}]
net-27 [{192.168.192.0/20 192.168.192.1/20 map[]}]
net-28 [{192.168.208.0/20 192.168.208.1/20 map[]}]
net-29 [{192.168.224.0/20 192.168.224.1/20 map[]}]
net-30 [{192.168.240.0/20 192.168.240.1/20 map[]}]
So Docker uses RFC1918 networks 172.16/12 and 192.168/16 with network masks that would divide both networks into 16 subnets.
I wonder if there is any way to affect this behavour. I use docker-compose in my CI pipeline to deploy apps and I strongly want to avoid hardcoding networks in docker-compose.yml files, since it will ruin it's portability.
Upvotes: 5
Views: 5144
Reputation: 3471
Looks like it will be available when docker-ce
v18.06
lands, you will be able to edit the /etc/docker/daemon.json
daemon settings with the following line:
{
"default-address-pools":[
{"base":"172.80.0.0/16","size":24}, {"base":"172.90.0.0/16","size":24}
]
}
See the Merged PR#36396 on GitHub for more information.
Upvotes: 8