Truong Dang
Truong Dang

Reputation: 3407

Docker limit user-defined bridge networks

I'm trying to create multiple user-defined bridge networks. But seem docker can create only 31 user-defined bridge networks per host machine. So, Can I increase more than 31 networks on my machine? Doesn't anyone know how I can do that, how to config my host machine? Thank you for your time!

Upvotes: 4

Views: 2142

Answers (3)

Mateusz Przybylek
Mateusz Przybylek

Reputation: 5825

Yer it is possible to extend network limit edit: /etc/docker/daemon.json:

{
   "default-address-pools": [
        {
            "base":"172.17.0.0/12",
            "size":16
        },
        {
            "base":"192.168.0.0/16",
            "size":20
        },
        {
            "base":"10.99.0.0/16",
            "size":24
        }
    ]
}

(add param if not exists), then sudo service docker restart

First two are default docker address pools, last is one of the private network

With this change you have additionally 255 networks. New containers attach to new address pool 10.99.0.0/16.

Upvotes: 1

Another Code
Another Code

Reputation: 3151

Since Docker version 18.06 the allocation ranges can be customized in the daemon configuration like so:

/etc/docker/daemon.json

{
  "default-address-pools": [
    {"base": "172.17.0.0/16", "size": 24}
  ]
}

This example would create a pool of /24 subnets out of a /16 range, increasing the bridge network limit from 31 to 255. More pools could be added as necessary. Note that this limits the number of attached containers per network to about 254.

Upvotes: 1

moebius
moebius

Reputation: 2259

Have a look at this:

This is due to the fact that it uses hardcoded list of broad network ranges – 172.17-31.x.x/16 and 192.168.x.x/20 – for bridge network driver.

You can get around this by manually specifying the subnet for each network created:

for net in {1..50} 
do 
  docker network create -d bridge --subnet=172.18.${net}.0/24 net${net}
done

Upvotes: 1

Related Questions