Port mapping doubt


In the image, the instructor has mapped 5000 and 5001 to port 80. How will that work? How are we exposing 2 ports at the same time?
Thank You.

Hello @mscoding7,

This is 2 separated docker containers (2 application instances), and port 80 is the port that the application is listening, it is not the host port so there should be no issue at all when you do that.
5000 (host) → 80 (voting-app)
5001 (host) → 80 (result-app)
It is only a problem if you used the same host port, then the 2nd command will return an error as the port was already allocated before.
Please refer to this document for docker run command and its flags.

Thanks,
Trung.

1 Like

Got it! Thanks, Trung.

1 Like

You’re welcome.

Happy learning,
Trung.