-1

I have some confusion on Docker ports.As i am not aware of the IP of server i cannot check myself.

In Dockerfile i can see below

EXPOSE 8080:8080

But to run the container is ran using the same image below command is used

docker run -d --restart=unless-stopped --name image1 -p 3000:8080 image1:latest

My confusion is wile creating image host port was given as 8080 in Dockerfile but when running the container from same image host port given was 3000.So in which port of host this container will run and why ?

AWS_Lernar
  • 627
  • 2
  • 9
  • 26

1 Answers1

3

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. To actually publish the port when running the container, use the -p flag on docker run to publish and map one or more ports, or the -P flag to publish all exposed ports and map them to high-order ports.

https://docs.docker.com/engine/reference/builder/

So 3000 port will exposed to your container.

Alexey Bril
  • 479
  • 4
  • 14