我在Ubuntu 16.04和docker-compose 1.8.1上使用docker 1.12.1。我正在尝试从https://docs.docker.com/compose/compose-file/#ipv4-address- ipv6-address获取Compose文件以运行。作为参考,我创建docker-compose.yml了以下内容:
docker-compose.yml
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
现在,运行docker-compose up产生
docker-compose up
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
未分配IPv6地址。
我已经尝试过:
--ipv6
--ipv6 --fixed-cidr-v6="2001:3984:3989::/64"
docker run -it busybox ifconfig
--fixed-cidr
bridge
没有成功 有任何想法吗?
事实证明,这确实是一个docker-compose 错误,该错误将在1.9.0中修复。
同时,有一种解决方法,可以使用以下docker network命令创建自定义网络:
docker network
docker network create --subnet=172.16.2.0/24 --gateway=172.16.2.1 --ipv6 --subnet=<myV6Network/subnet> dockerbridge
…然后可以docker-composed.yml通过编写使其在内部可用
docker-composed.yml
networks: dockerbridge: external: name: dockerbridge