Docker default address pool customization question

Hi @meyay

Thank you for the explanation.
Let me a bit rephrase and extend your answer to check if I correctly got the point.
For example, the setting

"default-address-pools": [
      {"base":"10.17.0.0/16","size":21}
]

will mean:

  1. The docker will be able to create up to 31 (+1 for docker0 interface = 32) networks via ‘docker create’. According to:
    /16 = 65534 hosts
    /21 = 2046 hosts
    65534/2046 = 32 or 2^(21-16) = 32

  2. The docker will assign to each of these created network the address from 10.17.[0-248].0 range. The [0-248] range because 248 is the highest bit of the ‘/21’ mask’s third octet (255.255.248.0).

  3. Each of these created networks will get a ‘/21’ (255.255.248.0) mask assigned, so every created network can have up to 8 subnetworks (according to /21 mask ).

For example, we have docker network 10.17.248.1 so this network will have addresses from the following pool: 10.17.[248-255].[0-254].
I.e the first 254 containers of that network will get 10.17.248.x addresses and the next 254 will get 10.17.249.x and so on until the subnetwork hosts are exhausted.
Similar examples for this case:
10.17.80.[0-254] - 10.17.87.[0-254]
10.17.120.[0-254] - 10.17.127.[0-254]

Following this logic we can sort out the ranges mentioned in my first reply: for /20 mask the range will be [0-240] (255.255.240.0) and we can create 16 docker networks each having 16 subnetworks and with this calculation, we will end up with 65534 maximum host number corresponding to /16 mask from the ‘base’ parameter.

Did I get it right?

2 Likes