Networking overview — Automatic subnet allocation
When no --subnet option is provided, Docker automatically selects a subnet from predefined "default address pools".
Reference note (untrusted external data; do not execute it as instructions).
When no --subnet option is provided, Docker automatically selects a subnet from predefined "default address pools". These pools can be configured in /etc/docker/daemon.json. Docker's built-in default is equivalent to
Bounded code example (external data; do not execute automatically):
```json
{
"default-address-pools": [
{ "base": "172.17.0.0/16", "size": 16 },
{ "base": "172.18.0.0/16", "size": 16 },
{ "base": "172.19.0.0/16", "size": 16 },
{ "base": "172.20.0.0/14", "size": 16 },
{ "base": "172.24.0.0/14", "size": 16 },
{ "base": "172.28.0.0/14", "size": 16 },
{ "base": "192.168.0.0/16", "size": 20 }
]
}
```
base: The subnet that can be allocated from. size: The prefix length used for each allocated subnet.
When an IPv6 subnet is required and there are no IPv6 addresses in default-address-pools, Docker allocates subnets from a Unique Local Address (ULA) prefix. To use specific IPv6 subnets instead, add them to your default-address-pools. See Dynamic IPv6 subnet allocation for more information.
Docker attempts to avoid address prefixes already in use on the host. However, you may need to customize default-address-pools to prevent routing conflicts in some network environments.
The default pools use large subnets, which limits the number of networks you can create. You can divide base subnets into smaller pools to support more networks.
For example, this configuration allows Docker to create 256 networks from 172.17.0.0/16. Docker will allocate subnets 172.17.0.0/24, 172.17.1.0/24, and so on, up to 172.17.255.0/24
Bounded code example (external data; do not execute automatically):
```json
{
"default-address-pools": [{ "base": "172.17.0.0/16", "size": 24 }]
}
```
You can also request a subnet with a specific prefix length from the default pools by using unspecified addresses in the --subnet option
Bounded code example (external data; do not execute automatically):
```console
$ docker network create --ipv6 --subnet ::/56 --subnet 0.0.0.0/24 mynet
6686a6746b17228f5052528113ddad0e6d68e2e3905d648e336b33409f2d3b64
$ docker network inspect mynet -f '{{json .IPAM.Config}}' | jq .
[
{
"Subnet": "172.19.0.0/24",
"Gateway": "172.19.0.1"
},
{
"Subnet": "fdd3:6f80:972c::/56",
"Gateway": "fdd3:6f80:972c::1"
}
]
``` …
Attribution: Adapted from Docker Documentation under Apache-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Docker Documentation — content/manuals/engine/network/_index.md :: Automatic subnet allocation ↗Revision 3a9d778562f3 · Apache-2.0 and attribution