I am using docker 1.12.1 on Ubuntu 16.04, and docker-compose 1.8.1. I am trying to get the Compose file from https://docs.docker.com/compose/compose-file/#ipv4-address-ipv6-
It turns out this is indeed a docker-compose bug that is going to be fixed in 1.9.0.
Meanwhile, there is a workaround by creating a custom network with the docker network
command:
docker network create --subnet=172.16.2.0/24 --gateway=172.16.2.1 --ipv6 --subnet=<myV6Network/subnet> dockerbridge
... which can then be made available inside docker-composed.yml
by writing
networks:
dockerbridge:
external:
name: dockerbridge
Yes. Docker compose supports IPv6 protocol and it was introduced into docker engine 1.5 onward. There is still issue with latest compose file format 3.3 so you could use the 2.1 format. Still docker swarm is not mature enough with advance networking configuration and it doesn't support IPv6, hence it is not included under 3.3 fil format. Here is sample example of File,
docker-compose.yml
version: ‘2.1’
services:
app:
image: busybox
command: ping www.google.com
networks:
app_net:
ipv6_address: 2001:3200:3200::20
networks:
app_net:
enable_ipv6: true
driver: bridge
ipam:
driver: default
config:
- subnet: 2001:3200:3200::/64
gateway: 2001:3200:3200::1
This docker compose file will create a new network called testping_app_net based on IPv6 network under the subnet 2001:3200:3200::/64 and container should get IPv6 address automatically assigned.
Let us bring up services using docker-compose up and see if the services communicates over IPv6 protocol:
docker-compose up -d
and you could verify the IPv6 address for each container using,
docker exec -it 905 ip addr
You will see that a new container gets IPv6 address – 2001:3200:3200::20 and hence they are able to communicate with each other.
Note : If you want to enable IPv6 on host machine, which by default uses IPv4 address you need to add these two line into the daemon.json under /etc/docker directory:
{
"ipv6": true,
"fixed-cidr-v6": "2001:db8:1::/64"
}
and restart the docker daemon by command:
$ sudo systemctl restart docker