Skip to content

Comments

[docker-29.x backport] Allow configured address with no configured subnet#51583

Merged
vvoland merged 2 commits intomoby:docker-29.xfrom
vvoland:51577-docker-29.x
Nov 24, 2025
Merged

[docker-29.x backport] Allow configured address with no configured subnet#51583
vvoland merged 2 commits intomoby:docker-29.xfrom
vvoland:51577-docker-29.x

Conversation

@vvoland
Copy link
Contributor

@vvoland vvoland commented Nov 24, 2025

- 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

  • Use IPAM info instead of config to check whether a configured IP address is in one of a container's subnets.
  • Remove the check that now prevents setting an IP address when the subnet was unspecified at network creation time.

- 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

Pick up fixes for:
- test_create_with_ipv6_address
- test_connect_with_ipv6_address

https://github.com/docker/docker-py/compare/65f7f0c..df3f8e2

Signed-off-by: Rob Murray <rob.murray@docker.com>
(cherry picked from commit 7e14b4d)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Rob Murray <rob.murray@docker.com>
(cherry picked from commit 84a251d)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@vvoland vvoland added this to the 29.0.4 milestone Nov 24, 2025
@vvoland vvoland self-assigned this Nov 24, 2025
Copy link
Contributor

@robmry robmry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thank you!

@vvoland vvoland marked this pull request as ready for review November 24, 2025 16:38
@vvoland vvoland requested a review from tianon as a code owner November 24, 2025 16:38
@vvoland vvoland merged commit 4612690 into moby:docker-29.x Nov 24, 2025
190 of 197 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants