Docker Community Forums

Share and learn in the Docker community.

Why different port number is mapped on ipv4 and ipv6 address for same expose port?

With docker version 20.10.6, build 370c289. observed that different port is assigned for same exposed port on ipv4 and ipv6 addresses. Why?

$ docker ps --format "{{.Ports}}"
0.0.0.0:49338->9999/tcp, :::49337->9999/tcp
0.0.0.0:49339->6379/tcp, :::49338->6379/tcp
0.0.0.0:49319->6379/tcp, :::49318->6379/tcp

I have the very same problem. In my case only installing the version 20.10.1 fixed the issue - because it does not assign IPv6 ports by default.

I have not found out any other way to disable IPv6 port assignment yet. My case is, that I require IPv6 available in the container itself, but the port being bound to only IPv4. Since I’m using Jenkins I can not use the syntax 0.0.0.0:80:80 for that, because I need the port bound to an arbitrary host port.

The problem accumulates due to using the classic swarm which maps the IPv6 ports to IPv4 ports, resulting in port overlaps.

Running Docker version 20.10.8, build 3967b7d on Debian 10 does not show the mentioned problem - all ports are available for IPv4 + IPv6 the way I expected it

~$ docker ps --format '{{.Ports}}' | grep '\->'
0.0.0.0:2180->80/tcp, :::2180->80/tcp
0.0.0.0:2080->80/tcp, :::2080->80/tcp, 0.0.0.0:2443->443/tcp, :::2443->443/tcp
80/tcp, 0.0.0.0:3443->443/tcp, :::3443->443/tcp
0.0.0.0:7080->80/tcp, :::7080->80/tcp, 0.0.0.0:7443->443/tcp, :::7443->443/tcp
0.0.0.0:1883-1884->1883-1884/tcp, :::1883-1884->1883-1884/tcp, 0.0.0.0:9001->9001/tcp, :::9001->9001/tcp

That means the bug (?) is gone/fixed with newer versions :slight_smile:

I had a short exchange over at Vendor in Libnetwork changes by arkodg · Pull Request #41805 · moby/moby · GitHub - I did check the version 20.10.7 since that is the must recent one on Ubuntu when I installed a few days ago.

There is also the issue Different port number are getting mapped on ipv4 and ipv6 for same expose port · Issue #42442 · moby/moby · GitHub which is not yet fixed.

The issue may not show from the start, it looks more like something coming after a while.