Docker Community Forums

Share and learn in the Docker community.

Creating macvlan docker network for existing VLAN w/ DHCP


(Eugenepark3) #1

hello, in our network, there is a VLAN configured with DHCP and IPAM (it is known as VLAN 31 or the 10.60.114.0/23)

Now, I’ve tried to create a macvlan network by:

docker network create -d macvlan --subnet=10.60.114.0/23 --gateway=10.60.114.1 -o parent=enp12s0 mymacvlan

on the host where it is already connected to VLAN 31 as shown on ifconfig

enp12s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9000
inet 10.60.114.102 netmask 255.255.254.0 broadcast 10.60.115.255
inet6 fd20:8b1e:b255:8136:225:b5ff:fe66:1143 prefixlen 64 scopeid 0x0
inet6 fe80::225:b5ff:fe66:1143 prefixlen 64 scopeid 0x20
ether 00:25:b5:66:11:43 txqueuelen 1000 (Ethernet)
RX packets 2782243254 bytes 2490894220806 (2.2 TiB)
RX errors 0 dropped 666 overruns 0 frame 0
TX packets 4017563076 bytes 4893760567659 (4.4 TiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

I’ve started a container using this macvlan network by:

docker run --rm -it --net mymacvlan rshcentos /bin/bash

and running ifconfig inside of a container shows:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9000
inet 10.60.114.2 netmask 255.255.254.0 broadcast 10.60.115.255
ether 02:42:0a:3c:72:02 txqueuelen 0 (Ethernet)
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

However, 10.60.114.2 is not reachable from anywhere from other hosts in VLAN31. I imagine it is something like 10.60.114.2 isnt registered in either DHCP or DNS of VLAN31.

Is there a way for tell the container using macvlan to be assigned of an ip address from DHCP via dhclient in VLAN31?

Thank you