0

I have tried the following

docker run -e lxc --lxc-conf="lxc.network.hwaddr=00:0C:29:88:30:CC" -i -t centos ifconfig

But as you can see from my outuput it does not chnage the mac address

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

I am running docker 1.3 on Ubuntu and the container generated from a centos7 image

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

I would appreciate any help to successfully change my mac address in my container.

Caustic
  • 940
  • 3
  • 12
  • 29
  • It looks like http://stackoverflow.com/a/18698166/395670 suggests to run docker daemon with `-e lxc` option. Not the `run` command with `-e lxc` option. `-e` in `docker run` is for setting environment variable(s). Whereas `-e lxc` in the above answer is meant to indicate to docker to use lxc as execution driver instead of default libcontainer. – Dharmit Dec 11 '14 at 09:52
  • What's the reason for changing it ? – Xavier Lucas Dec 11 '14 at 20:44
  • Per [this pull request](https://github.com/docker/docker/pull/8390), this feature will be added in the 1.4 release (which is due any day now). @XavierLucas I need this for an application that ties it's license to the server MAC address and therefore need the container to have a static address. – Kryten Dec 11 '14 at 22:49
  • Since 1.4 is out, just use 1.4 now? :) – Dharmit Dec 12 '14 at 07:25
  • moved the -e lxc command to config file and updated to version 1.4. used docker run -i -t --privileged --mac-address=00:0c:29:88:30:cc centos ifconfig And it made no difference. Still doesn't work. – Caustic Dec 15 '14 at 06:53

3 Answers3

2

If you look at the docker code at https://github.com/docker/docker/blob/v1.4.1/vendor/src/github.com/docker/libcontainer/netlink/netlink_linux.go#L528 you see that only non-broadcast local mac addresses are accepted. Search for "Organizationally Unique Identifier" in https://en.wikipedia.org/wiki/MAC_address for an explanation. In practice this means that the second character of the MAC has to be 2, 6, A or E.

If you run docker run --mac-address=00:0C:29:88:30:CC centos ifconfig you should see an error message that comes from the code pointed at above.

1

The way I do this is to run the container in privileged mode, then running ifconfig in the container to set it. But if you are looking for a solution which let you do that in the running command, I think you have to wait for other responses...

mgaido
  • 2,987
  • 3
  • 17
  • 39
0

first,check your system has lxc-start command ? if have lxc-start command #stop docker service ,use command run docker service sudo docker -d -e lxc ,look have any error is report. if have not lxc-start command apt-get install lxc-docker

  • Okay thanks, I did have lxc-start command and lxc-docker installed. Still no joy – Caustic Dec 15 '14 at 06:52
  • You run docker is a physical machine or virtual host? if is virtual host it is not unavailable.as to why it is unavailable,, and promiscuous mode related. –  Jan 14 '15 at 02:52