daemon: disallow container port 0#51684
Conversation
Signed-off-by: Albin Kerouanton <albin.kerouanton@docker.com>
Isn't |
|
This probably needs changes in the API change-log, and swagger (although we currently are not documenting the min/max values); Lines 4934 to 4951 in c64b781 |
It is, for the host port. I'm not changing the semantic of host port 0 here. There's no such thing as an ephemeral container port.
The API docs says:
Container port 0 is invalid and doesn't match the current definition (because container port 0 doesn't even exist). That's also why this change isn't done for a specific API version. |
Oh! You're right. That didn't sink in, and yes, that makes sense. |
- What I did
Although container port 0 is invalid, it's currently accepted by the Engine. Users could mistakenly declare
-p 0:0and end up with a port mapping that does nothing. In that case, the Engine would allocate an ephemeral host port and create an iptables / nftables rule that DNAT to container port 0. This is obviously wrong.Instead of failing silently, return an error message to the API client when it calls the
ContainerCreateendpoint.- Human readable description for the release notes