-
Notifications
You must be signed in to change notification settings - Fork 886
Description
I'm trying to connect containers on different hosts with each other and the outside world using the macvlan driver over IPv6. Additionally, the containers need to reach some IPv4 services, so I connected them through docker's default bridge network. The issue is the IPv4 network resets the IPv6 gateway. The two networks are:
[
{
"Name": "bridge",
"Id": "1eb235a94875b7451aa9b259e01c08d7d2771844d279df733214059f7db6067d",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.42.1"
}
]
},
"Internal": false,
"Containers": {},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
},
{
"Name": "macvlan",
"Id": "6f4191fe93879b6200719a16ab2723e195601a8875f35f9e432676c10c5d3c39",
"Scope": "local",
"Driver": "macvlan",
"EnableIPv6": true,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "172.18.0.0/16",
"Gateway": "172.18.0.1/16"
},
{
"Subnet": "w:x:y:z::/64",
"Gateway": "w:x:y:z::1"
}
]
},
"Internal": false,
"Containers": {},
"Options": {
"macvlan_mode": "bridge",
"parent": "ens15"
},
"Labels": {}
}
]
Each of them works correctly individually, but adding both through docker network connect always resets the IPv6 gateway. for example:
freva@docker:~$ sudo docker network create --ipv6 -d macvlan --subnet w:x:y:z::/64 --gateway w:x:y:z::1 -o parent=ens15 -o macvlan_mode=bridge macvlan
6f4191fe93879b6200719a16ab2723e195601a8875f35f9e432676c10c5d3c39
freva@docker:~$ sudo docker run -tid --name=macvlanbridge --net=macvlan --ip6=w:x:y:z::1078 ubuntu:14.10 bash
bb5b2ea440335379e83676d7968f921fde7307e66a318b3244f8f092ed98c570
freva@docker:~$ sudo docker inspect macvlan
[
...
"NetworkSettings": {
"Bridge": "",
"SandboxID": "c100356b5ba1ae5e369ae8d99cd8ba3bff5751869e8d39e25ad6c59929a16375",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/c100356b5ba1",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"macvlan": {
"IPAMConfig": {
"IPv6Address": "w:x:y:z::1078"
},
"Links": null,
"Aliases": [
"bb5b2ea44033"
],
"NetworkID": "6f4191fe93879b6200719a16ab2723e195601a8875f35f9e432676c10c5d3c39",
"EndpointID": "eb5bfc0a7f2f37203cd831282a577d1f7050e170c02f8b36e305c6a0455f439f",
"Gateway": "172.18.0.1",
"IPAddress": "172.18.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "w:x:y:z::1",
"GlobalIPv6Address": "w:x:y:z::1078",
"GlobalIPv6PrefixLen": 64,
"MacAddress": "02:42:ac:12:00:02"
}
}
}
}
]
freva@docker:~$ sudo docker stop macvlanbridge && sudo docker network connect bridge macvlanbridge && sudo docker start macvlanbridge
macvlanbridge
macvlanbridge
freva@docker:~$ sudo docker inspect macvlanbridge
[
...
"NetworkSettings": {
"Bridge": "",
"SandboxID": "bca5cbd08b2a8e8b5d4f96130ab98e180ed6498f9deafc993d24d633987da09d",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/bca5cbd08b2a",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "e46410c0e9f8104dd5190bbec5e2026ec1a91b31f8d679fa34562118e6c1c3cd",
"Gateway": "172.17.42.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.1",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:01",
"Networks": {
"bridge": {
"IPAMConfig": {},
"Links": null,
"Aliases": [],
"NetworkID": "1eb235a94875b7451aa9b259e01c08d7d2771844d279df733214059f7db6067d",
"EndpointID": "e46410c0e9f8104dd5190bbec5e2026ec1a91b31f8d679fa34562118e6c1c3cd",
"Gateway": "172.17.42.1",
"IPAddress": "172.17.0.1",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:01"
},
"macvlan": {
"IPAMConfig": {
"IPv6Address": "w:x:y:z::1078"
},
"Links": null,
"Aliases": [
"bb5b2ea44033"
],
"NetworkID": "6f4191fe93879b6200719a16ab2723e195601a8875f35f9e432676c10c5d3c39",
"EndpointID": "2af12e0af0593ffa388d11f5f15708743a5b136b21b46c25cff68a530176bc98",
"Gateway": "172.18.0.1",
"IPAddress": "172.18.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "w:x:y:z::1",
"GlobalIPv6Address": "w:x:y:z::1078",
"GlobalIPv6PrefixLen": 64,
"MacAddress": "02:42:ac:12:00:02"
}
}
}
}
]
freva@docker:~$ sudo docker exec -ti macvlanbridge bash
root@bb5b2ea44033:/# route -A inet6 -n
Kernel IPv6 routing table
Destination Next Hop Flag Met Ref Use If
w:x:y:z::/64 :: U 256 0 0 eth1
fe80::/64 :: U 256 0 0 eth0
fe80::/64 :: U 256 0 0 eth1
::/0 :: !n -1 1 1 lo
::1/128 :: Un 0 1 2 lo
w:x:y:z::1078/128 :: Un 0 1 0 lo
fe80::42:acff:fe11:1/128 :: Un 0 1 0 lo
fe80::42:acff:fe12:2/128 :: Un 0 1 0 lo
ff00::/8 :: U 256 0 0 eth0
ff00::/8 :: U 256 0 0 eth1
::/0 :: !n -1 1 1 lo
root@bb5b2ea44033:/# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.17.42.1 0.0.0.0 UG 0 0 0 eth0
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
172.18.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
After this, the IPv4 network works correctly, but the IPv6 is unreachable because no gateway is set. Simply running
sudo route -A inet6 add default gw w:x:y:z::1 eth1
will fix the macvlan net as well.
Is this related to #1141/#1142 or is the IPv6Gateway set to "" because bridge IPv6Gateway is not set and bridge comes before macvlan lexicographically? The expected outcome was that it should assume macvlan's IPv6 default gateway since it is the only IPv6 gateway that is actually set.