1

I'm new to Docker. I just learned it for 1 week. It really a perfect tool for deploying. I have some stuck with it too. I've created 3 containers as you see below:

(1) 0.0.0.0:3000->3000/tcp

(2) 0.0.0.0:5000->3000/tcp

(3) 0.0.0.0:4000->5000/tcp

So, the container's port is the port that I defined in my "index file" ( const port = 3000). What I'm going to ask here is why the container's port is used instead "EXPOSE" port in Dockerfile?

Thanks for any explanation.

stevenH
  • 155
  • 3
  • 13
  • 3
    Did you read the [documentation](https://docs.docker.com/engine/reference/builder/#expose)? The `EXPOSE` in the Dockerfile does nothing, it's just a documentation. – Mike Doe Aug 27 '19 at 07:56
  • Ya. I understood. I haven't read it carefully. Thank you so much. – stevenH Aug 27 '19 at 08:00

1 Answers1

4

Well As mentioned in comments by @emix to read the docs here is what mentioned in it

The EXPOSE instruction informs Docker that the container listens on the specified network ports at runtime. You can specify whether the port listens on TCP or UDP, and the default is TCP if the protocol is not specified.

and it continues

The EXPOSE instruction does not actually publish the port. It functions as a type of documentation between the person who builds the image and the person who runs the container, about which ports are intended to be published.

Kerolos William
  • 435
  • 2
  • 12
  • Thank you very much. I've read it and I found that EXPOSE be like a "contract" between the person who builds the image and the person who runs the container. @Kerolos William – stevenH Aug 27 '19 at 16:21