Home > Enterprise >  Understanding docker port mapping output of docker ps
Understanding docker port mapping output of docker ps

Time:12-21

If I run my docker container with:

docker run -it -p 5432:5432 postgres-words

Output of docker ps

CONTAINER ID   IMAGE            COMMAND                   STATUS         PORTS                                               NAMES
512416e853e1   postgres-words   "docker-entrypoint.s…"  Up 5 seconds   80/tcp, 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp   busy_chatelet

But with docker run -it -p 0.0.0.0:5432:5432 postgres-words, docker ps reports:

CONTAINER ID   IMAGE            COMMAND                     STATUS         PORTS                            NAMES
44131e2fa6ff   postgres-words   "docker-entrypoint.s…"     Up 4 seconds   80/tcp, 0.0.0.0:5432->5432/tcp   festive_chandrasekhar

My question is that what is the significance/meaning of extra :::5432->5432/tcp in the first case.

CodePudding user response:

:::5432->5432/tcp is referring to IPv6. :: in IPv6 has the same meaning as 0.0.0.0 in IPv4, because you can omit zeros in an IPv6 address and replace them with ::. It is also called the unspecified address. For reference you can also look at this question.

  • Related