Skip to content

docs: container run: document long syntax for --publish - #7554

Open
cansentay wants to merge 1 commit into
docker:masterfrom
cansentay:docs-publish-long-syntax
Open

cansentay wants to merge 1 commit into
docker:masterfrom
cansentay:docs-publish-long-syntax

Conversation

@cansentay

Copy link
Copy Markdown

Summary

The docker run reference only shows the short -p syntax. 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 --publish section of container_run.md: the published, target, and protocol options, an example, and a note that it has no option for the host IP. docker create already points to this page for its flags, so container_create.md is 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 port and docker inspect show the same port bindings for:

  • -p published=8080,target=80 and -p 8080:80
  • -p published=8053,target=53,protocol=udp and -p 8053:53/udp

Without published, Docker picks a random host port. Without target, docker run fails with no port specified.

make mddocs leaves the generated files unchanged, and make yamldocs runs fine.

Release notes (optional)

Created with: Claude Code, which drafted the docs change and ran the checks.

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>
@cansentay
cansentay requested review from a team and thaJeztah as code owners November 28, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant