cli icon indicating copy to clipboard operation
cli copied to clipboard

Unfriendly -p (--publish) syntax

Open p4vook opened this issue 5 years ago • 2 comments

It's difficult to understand docker run -p syntax. (TO:FROM). It took a while for me to realize where is the "from" part and where is the "to" part. This syntax is not described in help. I think that it would be better for new users to create alternative syntax variant (FROM->TO). That syntax, in my opinion, is more user-friendly. (copied from moby issue)

p4vook avatar Feb 10 '20 18:02 p4vook

We'll unlikely be able to change the syntax as it has been used for a long time.

We added advanced syntax; (--publish ...) which is more explicit on these parts.

That said, the documentation can use some improvements; there's a "concepts" page, but it only mentions the shorthand syntax;

  • https://docs.docker.com/get-started/docker-concepts/running-containers/publishing-ports/
  • but links to https://docs.docker.com/engine/network/#published-ports, which doesn't mention the advanced syntax
  • cli reference also doesn't mention advanced syntax and doesn't link to it; https://docs.docker.com/reference/cli/docker/container/run/#publish

thaJeztah avatar Apr 22 '25 16:04 thaJeztah

But I don't propose breaking the old syntax, just adding an alternative short-hand -p 80->8080 will be good.

It won't break any existing scripts.

p4vook avatar Apr 24 '25 19:04 p4vook