Docker Community Forums

Share and learn in the Docker community.

Publish port to specific ipv6 address

Hi,
it is possible to publish an port to an specific ipv4 address (for example x.x.x.1:80:80 and x.x.x.2:80:80), so is it possible to publish a port to a specific ipv6 or is it not. If not why? This should be implemented.

If I understand you correctly, you can actually do that. With ipv4’s dot notation, we distinguish the port from the IP by using a colon (’:’), in case of ipv6, enclose the IP part in square brackets.

E.g.

docker run --rm --name nginx -d -p [ipv6]:8080:80 nginx

Now verify the behaviour using curl.

Yesss this is what i meant. It is working but now i’ve got another problem:

1234:1234:1234:1234:1::2 is not the actual ipv6, and 1234:1234:1234:1234::/64 would be my subnet

$ docker run -d -p [1234:1234:123:1234:1::2]:80:80 --name container2 nginxdemos/hello
docker: Error response from daemon: driver failed programming external connectivity on endpoint container2 (d5499d1e5634a9e12a49d1445e55069981bad9f86d3232e4b63b3dcef45c7825): Error starting userland proxy: listen tcp [1234:1234:123:1234:1::2]:80: bind: cannot assign requested address.

I registered that subnet in the network interfaces:

ifcae eth0 inet6 auto
iface eth0 inet6 static
    address 1234:1234:1234:1234::
    netmask 64
    gateway fe80::1
    accept_ra 0
    autoconf 0
    privext 0
    up ip -6 route add local 1234:1234:1234:1234::/64 dev lo

Any idea why i can’t bind the port to an address from that range? But i can bind it to 1234:1234:1234:1234::

1 Like

The error message indicates the address you’re trying to bind with, does not exist on your system. Why you can bind to the network is where I’m not sure about. I’ll see if I can get some information on that.

I’ll see if I can get some information on that.

Okay thanks.

The error message indicates the address you’re trying to bind with, does not exist on your system

Hm, but when i try to ping the address or just bind the container to the host without an specific ipv6 address i can connect to the container with the specific ipv6 address i try to bind the container to.