业务需求容器需要分配一个 ipv6 地址
目前的我的方法是通过macvlan来分配,创建 macvlan 的代码是:
docker network create -d macvlan \
--subnet=10.47.242.0/24 \
--gateway=10.47.242.1 \
--subnet=2001:250:6000:10::/64 \
--gateway=2001:250:6000:10::1 \
-o parent=em1 \
-o macvlan_mode=bridge my_macvlan
em1 网卡的信息如下:
2: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 14:18:77:5c:c3:22 brd ff:ff:ff:ff:ff:ff
inet 10.47.242.191/24 brd 10.47.242.255 scope global noprefixroute em1
valid_lft forever preferred_lft forever
inet 10.47.242.190/24 brd 10.47.242.255 scope global secondary noprefixroute em1
valid_lft forever preferred_lft forever
inet 10.47.242.132/24 scope global secondary em1
valid_lft forever preferred_lft forever
inet6 2001:250:6000:10::a2f:f2bf/64 scope global noprefixroute
valid_lft forever preferred_lft forever
inet6 fe80::bd38:d6df:2161:618c/64 scope link noprefixroute
valid_lft forever preferred_lft forever
然后创建容器的时候通过ip6参数指定地址:
docker run -itd --privileged --network=my_macvlan --ip=10.47.242.212 --ip6=2001:250:6000:10::12 --name=demo commonimage:v3 /usr/sbin/init
进入容器查看网卡信息时只显示 v4 地址,不显示 v6 地址:
inet 10.47.242.212/24 scope global eth0
valid_lft forever preferred_lft forever`
inet6 fe80::42:aff:fe2f:f2d4/64 scope link
valid_lft forever preferred_lft forever
然后查看我创建的 macvlan 的信息,发现其中的EnableIPv6项是false:
"Name": "my_macvlan",
"Id": "3e65fedeff7a9cfeed65f92588c1d283010c51c827803fc7fec8400b5081e7f6",
"Scope": "local",
"Driver": "macvlan",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "10.47.242.0/24",
"Gateway": "10.47.242.1"
},
{
"Subnet": "2001:250:6000:10::/64",
"Gateway": "2001:250:6000:10::1"
}
]
},
现在就是卡在这里,通过 docker 的官网,百度,修改过 docker 的daemon.json,添加如下配置:
"ipv6": true,
"fixed-cidr-v6": "2001:250:6000:10::/64"
但是仍然不支持 ipv6,请问各位有没有遇到这种需求 /问题,可以指点一下.
目前的 docker 环境如下:
Running: 2
Paused: 0
Stopped: 5
Images: 28
Server Version: 1.12.6
Storage Driver: overlay2
Backing Filesystem: extfs
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge macvlan null overlay host
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 3.10.0-693.21.1.el7.x86_64
Operating System: NewStart Carrier Grade Server Linux 5.04
OSType: linux
Architecture: x86_64
CPUs: 12
Total Memory: 15.06 GiB
Name: linux-242-191
ID: X4NO:LW6Q:W6EQ:JEAB:DKM3:EPXZ:JCB4:D3HX:E22F:ZQIM:3GQP:MRXH
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
No Proxy: localhost,127.0.0.1,cdn-release-docker.artnj.zte.com.cn
Registry: https://index.docker.io/v1/
Insecure Registries:
cdn-release-docker.artnj.zte.com.cn
0.0.0.0/0
127.0.0.0/8
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.