【发布时间】:2015-02-09 15:35:11
【问题描述】:
我已经尝试了以下
docker run -e lxc --lxc-conf="lxc.network.hwaddr=00:0C:29:88:30:CC" -i -t centos ifconfig
但从我的输出中可以看出,它不会更改 mac 地址
eth0: flags=3<UP,BROADCAST> mtu 1500
inet 172.17.0.6 netmask 255.255.0.0 broadcast 0.0.0.0
inet6 fe80::42:acff:fe11:6 prefixlen 64 scopeid 0x20<link>
ether 02:42:ac:11:00:06 txqueuelen 1000 (Ethernet)
RX packets 1 bytes 90 (90.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1 bytes 90 (90.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
我在 Ubuntu 上运行 docker 1.3 和从 centos7 映像生成的容器
Client version: 1.3.2
Client API version: 1.15
Go version (client): go1.3.3
Git commit (client): 39fa2fa
OS/Arch (client): linux/amd64
Server version: 1.3.2
Server API version: 1.15
Go version (server): go1.3.3
Git commit (server): 39fa2fa
如果能帮助我成功更改容器中的 mac 地址,我将不胜感激。
【问题讨论】:
-
看起来stackoverflow.com/a/18698166/395670 建议使用
-e lxc选项运行docker daemon。不是带有-e lxc选项的run命令。docker run中的-e用于设置环境变量。而上面答案中的-e lxc是为了指示 docker 使用 lxc 作为执行驱动程序而不是默认的 libcontainer。 -
改的原因是什么?
-
根据this pull request,此功能将添加到 1.4 版本中(现在任何一天到期)。 @XavierLucas 对于将其许可证与服务器 MAC 地址绑定的应用程序,我需要它,因此需要容器具有静态地址。
-
既然1.4出来了,现在就用1.4吗? :)
-
将 -e lxc 命令移至配置文件并更新至 1.4 版。使用 docker run -i -t --privileged --mac-address=00:0c:29:88:30:cc centos ifconfig 并没有什么区别。还是不行。
标签: docker