See repo README for more details
- Host iface
eth0
is the parent interface for the macvlan network:
# 1. Start Docker
$ docker daemon
# Get info about the host interface
$ ip a show eth0
eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:50:56:32:5e:ba brd ff:ff:ff:ff:ff:ff
inet 172.16.86.148/24 brd 172.16.86.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::250:56ff:fe32:5eba/64 scope link
valid_lft forever preferred_lft forever
# 2. Create a network using the subnet that the master interface on the Docker host (not container) is on (eth0 & 172.16.86.0/24).
$ docker network create -d macvlan --subnet=172.16.86.0/24 -o host_iface=eth0 mcv-eth0
a4257eccc379cb4558eb71186c14beb84e67d4221d6a6f66591e588995edad95 <-- NetworkID of the new network is returned
# 3. Start the container on the new network (mcv-eth0)
$ docker run --net=mcv-eth0 -it --rm busybox
# 4. In the container view the slave interface (container side):
$ ip a show eth0
eth0@if2: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue
link/ether 2a:78:54:34:26:0b brd ff:ff:ff:ff:ff:ff
inet 172.16.86.2/24 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::2878:54ff:fe34:260b/64 scope link tentative
valid_lft forever preferred_lft forever
- Debug output from the plugin started with:
./macvlan-docker-plugin-0.3-Linux-x86_64 -d
:
(='o'=)[root@ub-148:binaries$]# ./macvlan-docker-plugin-0.3-Linux-x86_64 -d
DEBU[0000] The plugin absolute path and handle is [ /run/docker/plugins/macvlan.sock ]
INFO[0000] Macvlan network driver initialized successfully
DEBU[0069] Handshake completed
DEBU[0069] Capabilities exchange complete
DEBU[0069] Network Create Called: [ {NetworkID:a4257eccc379cb4558eb71186c14beb84e67d4221d6a6f66591e588995edad95 Options:map[com.docker.network.generic:map[host_iface:eth0]] IpV4Data:[{AddressSpace: Pool:172.16.86.0/24 Gateway:172.16.86.1/24 AuxAddresses:map[]}] ipV6Data:[]} ]
DEBU[0069] Libnetwork Opts Sent: [ host_iface ] Value: [ eth0 ]
DEBU[0116] The container subnet for this context is [ 172.16.86.2/24 ]
INFO[0116] Allocated container IP: [ 172.16.86.2/24 ]
DEBU[0116] Create endpoint response: &{Interface:{Address: AddressIPv6: MacAddress:7a:42:00:00:00:00}}
DEBU[0116] Create endpoint 9de0c5263a7b352b580165f68903cdaa42e46d6be106f02b2a78c18c188457bd &{Interface:{Address: AddressIPv6: MacAddress:7a:42:00:00:00:00}}
DEBU[0116] Join request: &{NetworkID:a4257eccc379cb4558eb71186c14beb84e67d4221d6a6f66591e588995edad95 EndpointID:9de0c5263a7b352b580165f68903cdaa42e46d6be106f02b2a78c18c188457bd SandboxKey:/var/run/docker/netns/b3d8aed261e6 Options:map[]}
DEBU[0116] Join response: &{Gateway:172.16.86.1 InterfaceName:{SrcName:9de0c DstName: DstPrefix:eth} StaticRoutes:[] DisableGatewayService:true}
DEBU[0116] Join endpoint a4257eccc379cb4558eb71186c14beb84e67d4221d6a6f66591e588995edad95:9de0c5263a7b352b580165f68903cdaa42e46d6be106f02b2a78c18c188457bd to /var/run/docker/netns/b3d8aed261e6
DEBU[0116] Endpoint info request: &{NetworkID:a4257eccc379cb4558eb71186c14beb84e67d4221d6a6f66591e588995edad95 EndpointID:9de0c5263a7b352b580165f68903cdaa42e46d6be106f02b2a78c18c188457bd}
DEBU[0116] Endpoint info 9de0c5263a7b352b580165f68903cdaa42e46d6be106f02b2a78c18c188457bd