Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between the docker port mapping notations: 5432/tcp vs 0.0.0.0:5432->5432/tcp?

When I call the command docker ps all my running docker containers are listed. Among other things, the port mappings are displayed in the PORTS column.

I can't figure out what the difference is between this notation: 5432/tcp and that notation: 0.0.0.0:5432->5432/tcp.

like image 443
zingi Avatar asked Oct 13 '25 01:10

zingi


1 Answers

5432/tcp means port 5432 is exposed of the container

When you EXPOSE 5432 (or any port you want) in your Dockerfile that’s going to tell Docker that your container’s service can be connected to on port 5432 of the container.

0.0.0.0:5432->5432/tcp means host port 5432 is mapped to container port 5432

When you publish any port, any traffic that comes on the host port will be forwarded to the published container port.

like image 104
kooskoos Avatar answered Oct 14 '25 19:10

kooskoos