libnetwork icon indicating copy to clipboard operation
libnetwork copied to clipboard

Explicit endpoint MAC address is not being set

Open gkm2021 opened this issue 6 years ago • 3 comments

Explicit endpoint MAC address is not being set. This is same as the issue described in closed issue [#1009]. I am on unbuntu 16.04 LTS. I am using the latest docker-ce version and I am using command like below to run docker: “docker run –mac-address=”02:42:c0:a8:84:22″ –net=my_macvlan_network …”

Docker seems to ignore the –mac-address option and is still assigning its own MAC Address.

gkm2021 avatar Jan 09 '19 17:01 gkm2021

I'm seeing the same running libnetwork in 5.4.1 on Centos7: Seems like we define a MAC addr and it's ignored as the driver automatically assigned a mac address:

docker run -d -it --name samiam --net MyNet --mac-address="02:42:ac:46:fc:ff" centos /bin/bash
4c2fb0fb8d46623dff8223c4afa6d36c5e40e7a169f75f5e5bf8588bfc7f660c
/usr/bin/docker-current: Error response from daemon: failed to create endpoint samiam on network MyNet: driver modified interface MAC address: endpoint interface MAC address present (02:42:ac:46:fc:ff). Cannot be modified with 76:a4:7a:19:c9:1f.; rolled back.

I've tried a few times with the same MAC addr, see the returned auto-generated mac below

02:42:ac:46:fc:ff
56:a4:7a:25:8b:c9

02:42:ac:46:fc:ff
0a:a4:7a:4f:50:3a

02:42:ac:46:fc:ff
5a:a4:7a:82:5c:ea

02:42:ac:46:fc:ff
76:a4:7a:19:c9:1f

02:42:ac:46:fc:ff
fe:a4:7a:56:1b:d6

I have debug logs for libnetwork if you think that could be beneficial,

Char0772 avatar Mar 14 '19 20:03 Char0772

@Char0772 @myobie what's the situation right now?

honglei avatar Jan 07 '20 13:01 honglei

Tested with docker 19.03.7, seems to be fixed

docker network create -d macvlan mymacvlan
docker run --mac-address=02:42:c0:a8:84:22 --net=mymacvlan alpine ip l

... the chosen MAC address is correctly set

bpascard avatar Mar 10 '20 23:03 bpascard