Allow configured address with no configured subnet by robmry · Pull Request #51577 · moby/moby (original) (raw)

- What I did

When a network is configured with no explicit --subnet, daemon.validateEndpointIPAddress tries to prevent a container from being started with a --ip address - with error "user specified IP address is supported only when connecting to networks with user configured subnets".

But the check didn't work in 28.x and older because, until #51134, IPAM config always contained a copy of the network's subnet - whether the user configured it, or it was allocated from the default pools.

So, it was possible to inspect (or guess!) a network's subnet and create a container with a specific address ... restore that behaviour.

- How I did it

- How to verify it

docker network create n1
docker network inspect n1
docker run --rm -ti --network n1 --ip <address in n1's subnet> alpine

New integration test that fails without the fix.

- Human readable description for the release notes

Allow creation of a container with a specific IP address when its networks were not configured with a specific subnet