Custom IP Range for new networks

Hello,

is there any way to specify a custom IP-Range that docker uses to make subnets out of it and dynamically assign them to new networks?
I know I can tell docker to use a specifiy subnet when creating a network, but I want docker to automatically assign a subnet out of a bigger subnet.
This is useful when creating networks e.g. by script, so you don’t have to manually take care for already used subnets.

I tried the option “bip” and “fixed-cidr” in daemon.json but they seem to only affect the default docker bridge network.

My Problem is that the default subnets conflict with existing internal IPs.

Thank you in advance

I found the answer myself.

You can specify a ‘default-address-pool’ in /etc/docker/daemon.json. As an example:

{
  "default-address-pools": [
    {
      "base": "192.168.56.0/21",
      "size": 28
    }
  ]
}

After a restart of docker, new created networks will be dynamically assigned a /28 subnet of 192.168.56.0/21.

For at least a bit of documentation see aboch’s comment here: https://github.com/moby/moby/pull/29376
And the option is listed here: https://docs.docker.com/engine/reference/commandline/dockerd/

In my eyes the option is hard to find.