0

I am just getting started with Docker and I've been trying to read through some other people's Dockerfiles and I occasionally see the command EXPOSE $PORT. Now I noticed that some people add it and some people don't, some tutorials tell you to add that command while others don't even mention it.

I looked up the command in the Dockerfile reference for the command and it almost sounds like it's there to just tell whoever is reading the file that this is the intended port that the container will be listening on?

In that case, does the value of the port you expose have any effect on what happens when the container runs?

djvaroli
  • 1,223
  • 1
  • 11
  • 28
  • 1
    In modern Docker, it does almost nothing and serves as mostly documentation. If you don't also publish the port with `-p` it happens to show up in `docker ps` output, but that's about the only visible effect. – David Maze Apr 08 '21 at 13:11
  • OK, that's very helpful, thank you! – djvaroli Apr 09 '21 at 15:33

0 Answers0