Reputation: 57
I am running my docker compose with postgres
Name Command State Ports
-------------------------------------------------------------------------------------------------------------
docker-compose_postgres_1 docker-entrypoint.sh postgres Up 0.0.0.0:5432->5432/tcp,:::5432->5432/tcp
I didn't understand the 2nd part of the portmapping here :::5432->5432/tcp. Can somebody explain me this?
Upvotes: 0
Views: 92
Reputation: 18203
To add to @frippe's comment: it's the IPv6 equivalent of any address (h/t: @frippe) plus port number. In IPv6, if there are zeros in continuity in the IP address, you can suppress them: https://datatracker.ietf.org/doc/html/rfc1924#section-3. Since there would be eight times four zeros otherwise (IPv6 is using hexadecimal notation), it is much cleaner to write it this way. The reason for using the hexadecimal notation is that an IPv6 address contains 128 bits. Each of the symbols in an IPv6 address replaces four bits. That means that an IPv6 address consists of:
8 parts x 4 bits x 4 symbols = 128 bits
Symbols 0 - 9
represent the same numbers as in the decimal system, but are written with four bits. Numbers that would be higher than nine are using symbols A - F
, where A
represents 10
and F
represents 15
.
This is why the notation is called hexadecimal: there are 16 elements, i.e., 0 - 15
.
So, the first two columns ::
represent the "any" part and the third column is used to mark the start of the port part.
:::5432
:: -> suppressed zeros in IPv6, could be written as
0000:0000:0000:0000:0000:0000:0000:0000
: -> splitting the IP address and port
0000:0000:0000:0000:0000:0000:0000:0000:5432
To further expand, the IP address and port combination is called a socket. This is a bit different compared to what you would otherwise call a socket. See a great explanation here: What is the difference between a port and a socket?.
Upvotes: 3