-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow empty host port in --publish flag #6808
Allow empty host port in --publish flag #6808
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mheon The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
bb3bfb9
to
52d4583
Compare
pkg/specgen/generate/ports.go
Outdated
// If we have an exact duplicate, just continue | ||
if testCPort == hPort && testHPort == cPort { | ||
continue | ||
if hPort != 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't this just an else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point
This should be better documented in the man pages. |
I didn't believe that this was actually legal, but it looks like it is. And, unlike our previous understanding (host port being empty means just use container port), empty host port actually carries the same meaning as `--expose` + `--publish-all` (that is, assign a random host port to the given container port). This requires a significant rework of our port handling code to handle this new case. I don't foresee this being commonly used, so I optimized having a fixed port number as fast path, which this random assignment code running after the main port handling code only if necessary. Fixes containers#6806 Signed-off-by: Matthew Heon <[email protected]>
52d4583
to
3601b96
Compare
Added to manpages |
Tests are green |
LGTM |
/lgtm |
I didn't believe that this was actually legal, but it looks like it is. Simple enough fix (just remove the error message), too.
Fixes #6806