Apoorv Tyagi Thanks for the great article. Wondering what is the use of this docker run -dp 5000:5000 hello-python. Since we specify that we want to expose the port 5000 in dockerfile.
"EXPOSE" instruction does not actually publish the port.(it's just a way of telling the person who runs the container about which ports are intended to be published)
To actually publish the port you need to run the container & use the -p flag with it
Even though i have mentioned 5000 in my Dockerfile, i can run my container on 5500 if i do docker run -dp 5500:5000 hello-python
Because i wanted to check if my container is running fine i used the docker run command
I hope it makes sense :)
Apoorv Tyagi Thanks. just another small question why :5000 next to 5500 if port is 5500
Kannan 5500 is the container port that we published. Publishing ports means mapping container ports to the host application(my flask app in this case) so that the ports are available to services outside of Docker container.
In order to do that the syntax is docker run -p <your container port>:<host app exposed port><imageName>
This means anyone connecting to the host(flask app) over port 5000 will be routed to my container via port 5500.