我尝试过以下几种方法
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上运行docker1.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地址,我将不胜感激。
发布于 2014-12-19 17:50:56
如果你查看https://github.com/docker/docker/blob/v1.4.1/vendor/src/github.com/docker/libcontainer/netlink/netlink_linux.go#L528上的docker代码,你会发现只接受非广播的本地mac地址。在https://en.wikipedia.org/wiki/MAC_address中搜索“组织唯一标识符”以获取解释。实际上,这意味着MAC的第二个字符必须是2、6、A或E。
如果您运行docker run --mac-address=00:0C:29:88:30:CC centos ifconfig,您应该会看到一条错误消息,该消息来自上面提到的代码。
发布于 2014-12-11 16:15:35
我这样做的方法是在特权模式下运行容器,然后在容器中运行ifconfig来设置它。但是如果你正在寻找一种解决方案,让你在运行的命令中做到这一点,我认为你必须等待其他响应……
发布于 2014-12-12 11:10:32
首先,检查你的系统是否有lxc-start命令?如果有lxc-start命令#stop docker service,使用命令run docker service sudo docker -d -e lxc,查看是否有错误被报告。如果没有lxc-start命令apt-get则安装lxc-docker
https://stackoverflow.com/questions/27417981
复制相似问题