I am using docker 1.12.1 on Ubuntu 16.04, and docker-compose 1.8.1. The Compose file from https://docs.docker.com/compose/compose-file/#ipv4-address-ipv6-address does not run correctly: The ipv6_address
setting seems to be ignored. I tried on various machines.
For reference, I created docker-compose.yml
with the following content:
version: '2'
services:
app:
image: busybox
command: ifconfig
networks:
app_net:
ipv4_address: 172.16.238.10
ipv6_address: 2001:3984:3989::10
networks:
app_net:
driver: bridge
driver_opts:
com.docker.network.enable_ipv6: "true"
ipam:
driver: default
config:
- subnet: 172.16.238.0/24
gateway: 172.16.238.1
- subnet: 2001:3984:3989::/64
gateway: 2001:3984:3989::1
Now, running docker-compose up
produces
Creating network "tmp_app_net" with driver "bridge"
Creating tmp_app_1
Attaching to tmp_app_1
app_1 | eth0 Link encap:Ethernet HWaddr 02:42:AC:10:EE:0A
app_1 | inet addr:172.16.238.10 Bcast:0.0.0.0 Mask:255.255.255.0
app_1 | inet6 addr: fe80::42:acff:fe10:ee0a/64 Scope:Link
app_1 | UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
app_1 | RX packets:4 errors:0 dropped:0 overruns:0 frame:0
app_1 | TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
app_1 | collisions:0 txqueuelen:0
app_1 | RX bytes:520 (520.0 B) TX bytes:90 (90.0 B)
app_1 |
app_1 | lo Link encap:Local Loopback
app_1 | inet addr:127.0.0.1 Mask:255.0.0.0
app_1 | inet6 addr: ::1/128 Scope:Host
app_1 | UP LOOPBACK RUNNING MTU:65536 Metric:1
app_1 | RX packets:0 errors:0 dropped:0 overruns:0 frame:0
app_1 | TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
app_1 | collisions:0 txqueuelen:1
app_1 | RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
app_1 |
tmp_app_1 exited with code 0
The IPv6 address is not assigned. That seems to be a bug, either in ipv6_address
itself, or there is some required configuration step missing from the documentation.
For further information, here's what I already tried:
--ipv6
--ipv6 --fixed-cidr-v6="2001:3984:3989::/64"
docker run -it busybox ifconfig
actually gives me an IPv6 address here (from the --fixed-cidr
subnet which is assigned to the default bridge
network)I suppose this is related to #3430
IPv6 and docker need ip6tables rules and ip -6 neigh add proxy
if you planing local access (another host you network)
about such
-A FORWARD -i eth0 -j DOCKER-PUB
-A FORWARD -j DOCKER-ISOLATION
-A FORWARD -o docker0 -j ACCEPT
-A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i docker0 ! -o docker0 -j ACCEPT
-A FORWARD -i docker0 -o docker0 -j ACCEPT
-A DOCKER-ISOLATION -j RETURN
with each container
ip -6 neigh add proxy 2001:3984:3989::10 dev eno1
note that IPv6 containers will be available globally
@f-andrey iptables etc. has nothing to do with the missing _assignment_ of the IPv6 address, right?
Sorry, my distraction, did not pay attention docker-compose
I still decided not to deal with the automatic creation of the network and create them manually. And used as external
docker network create --subnet=172.16.238.0/24 --gateway=172.16.238.1 --ipv6 --subnet=2001:3984:3989::/64 -o "com.docker.network.bridge.enable_icc"="true" -o "com.docker.network.bridge.enable_ip_masquerade"="false" -o "com.docker.network.bridge.host_binding_ipv4"="0.0.0.0" -o "com.docker.network.bridge.name"="docker1" -o "com.docker.network.driver.mtu"="1500" app_net
@f-andrey Thanks, this is a suitable workaround. I ended up using docker network create --subnet=172.16.2.0/24 --gateway=172.16.2.1 --ipv6 --subnet=<myV6Network/subnet> -o "com.docker.network.bridge.enable_ip_masquerade"="true" dockerbridge
@shin- #3994 was merged for 1.9.0, and also appears in the change log. However, the result of running docker-compose up
with the above Dockerfile (which is still the same in the docs!) is unchanged, i.e. the IPv6 address is missing, despite the fix.
I thought your fix addresses this issue. Can you elaborate? Thanks!
@peterthomassen Sorry for the confusion. You will need to add enable_ipv6
in your network definition going forward. I'll look into getting the documentation updated.
version: '2.1'
services:
app:
image: busybox
command: ifconfig
networks:
app_net:
ipv4_address: 172.16.238.10
ipv6_address: 2001:3984:3989::10
networks:
app_net:
enable_ipv6: true
driver: bridge
ipam:
driver: default
config:
- subnet: 172.16.238.0/24
gateway: 172.16.238.1
- subnet: 2001:3984:3989::/64
gateway: 2001:3984:3989::1
Edit: Must also use version 2.1 for support of the new flag.
With the docs change merged, I'll go ahead and close this. Let me know if you're still encountering issues.
Although "enable_ipv6: true" does work in docker-compose file version 2.1, it does not work in 3.x
Any advice regarding enabling IPv6 in current versions?
ERROR: The Compose file './docker-compose.yml' is invalid because:
networks.app_net value Additional properties are not allowed ('enable_ipv6' was unexpected)
I'm also blocked with compose 2.1 for IPv6, any idea how to solve this ?
@akomakom @valentin2105
try to:
networks:
app_net:
driver: bridge
driver_opts:
com.docker.network.enable_ipv6: "true"
ipam:
driver: default
config:
- subnet: 172.16.238.0/24
gateway: 172.16.238.1
- subnet: 2001:3984:3989::/64
gateway: 2001:3984:3989::1
@shoonoise With Version '3.2' :
bash-4.3# ip -6 addr
bash-4.3#
Not any IPv6 ..
Most helpful comment
@peterthomassen Sorry for the confusion. You will need to add
enable_ipv6
in your network definition going forward. I'll look into getting the documentation updated.Edit: Must also use version 2.1 for support of the new flag.