Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase maximum Docker Network on one server?

In my computer, I can create more maximum 29 Docker Network, like that.

for num in `seq -w 100`; do
    echo "Create network: $num"
    docker network create $num
done

After creating 29 Docker Network, I get error:

Error response from daemon: failed to parse pool request for address space "LocalDefault" pool "" subpool "": could not find an available predefined netw
ork

My Question: How to increase maximum Docker Network on one server?

Because I used to test many docker-compose should require more network.

Thank you.

like image 852
Cuong Tran Avatar asked Jan 12 '17 09:01

Cuong Tran


2 Answers

For every network, docker reserves a private IP pool and reserves a range of IP addresses.

Private address range is defined here(https://en.wikipedia.org/wiki/Private_network).

Docker uses following pool:

172.17.0.0/16 - 172.31.0.0/16 - 15

192.168.0.0/20 - 192.168.224.0/20 - 15

Default bridge network takes up 1. Thats why you see the limit at 29. This limit does not apply for other networks like overlay.

like image 115
Sreeni Avatar answered Sep 28 '22 01:09

Sreeni


If you want to extend network limit without breaking existing containers/networks 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 values 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.

like image 36
GetoX Avatar answered Sep 28 '22 01:09

GetoX