now that some of my server applications are packed into Docker containers, I'm trying to deploy them on my production servers. My containers should be accessible by IPv4 and IPv6 at the same time. Usually that is no problem: If you map container ports to host ports e.g. via docker-compose, Docker will use available IPv6 and IPv4 addresses.

My problem is: There is not only one IPv4 and IPv6 address available on my server, but multiple. My application container should only use one specific IPv4 address and one specific IPv6 address of the host. You can bind a container port to a IPv4-address by using the following docker-compose syntax:

    - ""

(See https://docs.docker.com/compose/compose-file/#ports)

Unfortunately I couldn't find any information how to do that with IPv6 addresses. Is there any way I can bind a container port to a single, specific IPv6 address on my Docker host?

  • I haven't used Docker, but I assume the process is similar to VM situation. With VMs, I create a bridge interface, which has host physical interface and VM virtual interface as a member. Then, inside the VM I assign the public IPv6 address which I want the VM to have. Replace the VM with container in the description and you should have the way to do it. – Tero Kilkanen Apr 4 '17 at 8:33

As of version 1.15 of docker-compose (possibly 1.14) you can now use additional colons in the port definition for IPv6:

version: '3.3'

    image: nginx
    - "::1:8080:80"

The relevant issue can be found here: https://github.com/docker/compose/issues/2663

| improve this answer | |

My solution is to bind all container exposed ports to and then forward external v4 and v6 IP-connections via HAProxy to Maybe not the nicest way to do it, but a solution for me.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.