I need to enable both IPv4/IPv6 dualstack support for my docker containers. My docker compose file is version 3. By default IPv4 is enabled but how do I enable IPv6 for my docker containers/network?
I have already tried to update the docker daemon by updating the daemon.json and I know the updates are being recognised because Docker will not start if there are errors in the file. I have restarted Docker (not just my containers) after making the changes, but still no IPv6 addresses for my containers.
I have discovered that enable_ipv6: true
in the docker compose file is not valid for version 3 or greater and I would not like to downgrade by file version.
My updated daemon.json:
{
"ipv6": true,
"fixed-cidr-v6": "2001:db8:1::/64"
}
When I inspect my containers, after making changes to the daemon.json, with docker inspect {id} I see the following:
"NetworkSettings": {
"Bridge": "",
"SandboxID": "df737362d15722fc1b0501ac256ba371417fe513dede807f2a17bd0524630a31",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"9000/tcp": null
},
"SandboxKey": "/var/run/docker/netns/df737362d157",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"healixportal_default": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"php-fpm",
"9b8a7aee156b"
],
"NetworkID": "5523ae0a4a936b47f212f0e301b64cbbad1f279a33107ed1f624e28d2df96c66",
"EndpointID": "880e13b64bec3fc84ae5a0abb5054bda66d5f439da6853f3538eb33be14b256b",
"Gateway": "172.18.0.1",
"IPAddress": "172.18.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:12:00:02",
"DriverOpts": null
}
}
}
So there is still no IPv6 address assigned to my container...
To disable IPv6 on the mailcow network, open docker-compose. yml with your favourite text editor and search for the network section (it's near the bottom of the file). Change enable_ipv6: true to enable_ipv6: false : networks: mailcow-network: [...]
Yes, Docker supports IPv6. IPv6 networking is only supported on Docker daemons running on Linux hosts.
Create an external network with docker network create <network name> In each of your docker-compose. yml configure the default network to use your externally created network with the networks top-level key. You can use either the service name or container name to connect between containers.
According to this issue for the compose repo IPv6 is not supported like that yet, but there is a workaround that might do the trick for you:
You must comment
enable_ipv6: true
, and leave all the others parameters as the documentation says. After running:
$ sudo docker-compose build
Then execute:
$ docker network create --driver bridge --ipv6 --subnet fd15:555::/64 --subnet 172.16.238.0/24 containerName-dockerfile_app_net --attachable
$ sudo docker-compose up -d
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With