Repository navigation
Conversation
The --publish flag accepts a long syntax (published=8080,target=80), but the reference only described the short syntax, which makes it easy to mix up the host and container ports. Signed-off-by: Can Sentay <cansen1392@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
docker runreference only shows the short-psyntax. As noted in #2324, it doesn't mention the long syntax (published=8080,target=80), which names the host and container ports instead of relying on their order.This adds a short subsection on the long syntax to the
--publishsection ofcontainer_run.md: thepublished,target, andprotocoloptions, an example, and a note that it has no option for the host IP.docker createalready points to this page for its flags, socontainer_create.mdis unchanged.#7209 (open) spells out the short syntax at the top of the same section. The two changes don't overlap and merge cleanly.
Checks
With Docker 29.9.3,
docker portanddocker inspectshow the same port bindings for:-p published=8080,target=80and-p 8080:80-p published=8053,target=53,protocol=udpand-p 8053:53/udpWithout
published, Docker picks a random host port. Withouttarget,docker runfails withno port specified.make mddocsleaves the generated files unchanged, andmake yamldocsruns fine.Release notes (optional)
Created with: Claude Code, which drafted the docs change and ran the checks.