zingi
zingi

Reputation: 1377

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.

Upvotes: 4

Views: 1647

Answers (1)

kooskoos
kooskoos

Reputation: 4879

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.

Upvotes: 4

Related Questions