Skip to content

Add an ipam option for docker network create to allow hinting a different preferred size than what may be configured in default-address-pools #50107

@danegsta

Description

@danegsta

Description

When doing local Docker development, the default /16 (and /20) subnet sizes configured in default-address-pools can result in available default network pools being exhausted if networks aren't regularly cleaned up. For scenarios where a smaller subnet (say /24) may be viable, the available workarounds of manually configuring network subnets or overriding the default-address-pools configuration require per-machine configuration (and educating users how to make the appropriate change or select an available network range) and neither are particularly viable for tooling or libraries that need to create one or more networks with a configuration that can work on any developers machine.

I'd like to propose a new optional ipam option value that could be passed to docker network create and act as a hint for a preferred network subnet size from the default pools. This hint would be optional and the ipam driver could chose to ignore the value; the created network wouldn't be guaranteed to match the requested size. For example, if the default address pool was configured to issue /24 subnets and a request indicated a preferred size of 20, the user may still receive a /24 network. Or in the event that a user indicated that they preferred an invalid network subnet size (a non numeric value, a value greater than is allowed for the current subnet IP type (IPv4, IPV6), etc.).

Effectively, I'd like to see something like the following:

docker network create --ipam-opt preferred_default_address_pool_size=24 test

For the default address pool configurations, this might return 172.18.0.0/24 as the subnet for the newly created network.

The important thing is that the value is simply a hint that a network can accept a smaller subnet and the ipam driver can choose to honor or ignore it as makes sense on a request-by-request basis.

Metadata

Metadata

Assignees

Labels

kind/featureFunctionality or other elements that the project doesn't currently have. Features are new and shinystatus/0-triage

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions