1

In the docs I noticed this: "You publish ports using the PUBLISH keyword in the Dockerfile".

Is this a bad idea? I have literally never seen a dockerfile with a PUBLISH directive, why isn't this used? And how do I use it in conjunction with -p or -P with docker run?

red888
  • 22,770
  • 38
  • 161
  • 304

1 Answers1

2

That documentation was incorrect and has been fixed. There is no PUBLISH Dockerfile directive, it's a run time option only

  -p, --publish list                   Publish a container's port(s) to the host
  -P, --publish-all                    Publish all exposed ports to random ports

For the details of the two concepts see Difference between "expose" and "publish" in docker

Matt
  • 59,496
  • 7
  • 135
  • 138