I am using Ubuntu 18.04 on DigitalOcean, with IPv6 turned on:
PUBLIC IPV6 ADDRESS:
xxxx:xxxx:2:d0::216f:3001
PUBLIC IPV6 GATEWAY:
xxxx:xxxx:2:d0::1
CONFIGURABLE ADDRESS RANGE:
xxxx:xxxx:2:d0::216f:3000 - xxxx:xxxx:2:d0::216f:300f
According to this page: https://docs.docker.com/v17.09/engine/userguide/networking/default_network/ipv6/#docker-ipv6-cluster
Is it correct to put the 16 IPv6 addresses like this?
{
"ipv6": true,
"fixed-cidr-v6": "xxxx:xxxx:2:d0::216f:3000/124"
}
Or, is it just fine to use these (as if something like 192.168.0.x)?
{
"ipv6": true,
"fixed-cidr-v6": "2001:db8::c008/125"
}
Anyway I have tried the first one.
docker run -d --name ipv6test alpine ash -c "ping6 2606:4700:4700::1111"
I "docker inspect" for the IPv6 address. I make the NDP record:
ip -6 neigh add proxy xxxx:xxxx:2:d0::216f:3004 dev eth0
In this case, the container could communicate with the outside world.
Testing finished. I want to apply IPv6 to my project. It starts with docker-compose.
According to this page: https://docs.docker.com/compose/compose-file/#ipv4_address-ipv6_address
version: "3.7"
services:
app:
image: nginx:alpine
networks:
app_net:
ipv6_address: xxxx:xxxx:2:d0::216f:3010
networks:
app_net:
ipam:
driver: default
config:
- subnet: "xxxx:xxxx:2:d0::216f:3000/124"
Inside the container, no connection could be made:
# ping6 2606:4700:4700::1111
PING 2606:4700:4700::1111 (2606:4700:4700::1111): 56 data bytes
ping6: sendto: Address not available
Have I missed anything?
Thanks.
Best Answer
Might be a little bit late, but this is the setup that worked for me on DigitalOcean:
/etc/docker/daemon.json
:sudo systemctl restart docker
Add to your
docker-compose.yml
:Basically it seems the default is to disable IPv6 and we need to enable it in sysctl.
EDIT: Actually this allows the docker container to obtain an IPv6 address and perform IPv6 name resolution, but somehow it cannot send data (Network unreachable).
Although docker containers started with
docker
directly, which runs on the defaultbridge
network, is able to access external IPv6 hosts, docker containers started bydocker-compose
runs in its dedicated network, so maybe one will need more routing work. My use case was actually limited (socat
as IPv4 to IPv6 proxy) so I simply resorted to using the host network directly, with: