How Do I Enable IPv6 Support for Docker Containers?
My docker containers currently have IPv6 addresses but I can't ping Google from the container with IPv6.
PING google.com(nrt12s23-in-x0e.1e100.net (2404:6800:4004:80a::200e)) 56 data bytes
^C
--- google.com ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3068ms
How can I get IPv6 connectivity to work from my containers?
2 Replies
After doing some investigating, I think I figured out how you can get this setup. The first thing you'll need is a IPv6 /64 block of addresses. If you don't have one you can open a support ticket from Cloud Manager and request one.
Once you have an IPv6 /64 block assigned, you'll need to restart your Linode before you can begin using this pool on your Linode. Once you've restarted your Linode, you can follow the steps below to get your Docker containers to pick this change up.
- Edit the
/etc/docker/daemon.json
file to include the following information, replacing $IPV6PREFIX with the prefix you were assigned. If it doesn't exist, create this file.
{
"ipv6": true,
"fixed-cidr-v6": "$IPV6PREFIX/64"
}
- Restart Docker by running
sudo systemctl restart docker
. This will restart the default Docker bridge network and provide it with an IPv6 address from your /64 pool.
You should now be able connect to external services using IPv6 from any Docker containers connected to the default network bridge. You can test this by running docker run --rm -t busybox ping6 -c 4 google.com
which will create a busybox container for you to test from.
If you're using user-defined bridges, I'd recommend checking out Docker's Bridge Networks documentation for some additional help with configuring those for IPv6.
Another solution is to use IPv6 NAT, with this solution you do not need to open a ticket to get an IPv6/64 block, there is a project to help you set it up, https://github.com/robbertkl/docker-ipv6nat
there only need two-step to set it up,
First, enable IPv6 of Docker, add this to /etc/docker/daemon.json
{
"ipv6": true,
"fixed-cidr-v6": "fd00::/64"
}
Second, run the IPv6 NAT docker https://github.com/robbertkl/docker-ipv6nat#docker-container
This solution is much more simple, it just NAT like IPv4, and you do not need to worry about some private containers that you do not want to open the port to the public Internet but want to use in the local network, docker's IPv4 NAT works like this, also IPv6. I think this is a much better solution.