Docker Community Forums

Share and learn in the Docker community.

Macvlan network and host to container connectity


(Guardiande) #1

Hi,

I’m wrestling with having a container on a macvlan network and still being able to talk to the host.

General setup
Host OS Ubuntu 16.04
Docker version 17.09.1-ce, build 19e2cf6
LAN 192.168.47.0/24
Host IP 192.168.47.250 (standard Ubuntu br0 bridge)
Container IP 192.168.47.34

Docker network setup

docker network create -d macvlan --subnet 192.168.47.0/24 --gateway 192.168.47.201 -o parent=br0 -o macvlan_mode=bridge physical

Bridging another macvlan link to allow container host connectivity

ip link add mac0 link br0 type macvlan mode bridge
ip addr add 192.168.47.250/24 dev mac0
ip link set mac0 up

Testing connectivity to LAN server (not host)

docker run --network physical -it --rm busybox ping 192.168.47.252
PING 192.168.47.252 (192.168.47.252): 56 data bytes
64 bytes from 192.168.47.252: seq=0 ttl=64 time=0.498 ms
64 bytes from 192.168.47.252: seq=1 ttl=64 time=0.323 ms
64 bytes from 192.168.47.252: seq=2 ttl=64 time=0.394 ms
^C
--- 192.168.47.252 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.323/0.405/0.498 ms

Testing with host (not working)

docker run --network physical -it --rm busybox ping 192.168.47.250
PING 192.168.47.250 (192.168.47.250): 56 data bytes
^C
--- 192.168.47.250 ping statistics ---
3 packets transmitted, 0 packets received, 100% packet loss

Any ideas?


(Bwstitt) #2

Did you ever figure this out? I am trying to run a docker registry with macvlan, but my host can’t pull from it :frowning:

https://sreeninet.wordpress.com/2016/05/29/docker-macvlan-and-ipvlan-network-plugins/ has the same steps as the official docs. I think maybe a kernel setting or something is in the way. I’m running Ubuntu with kernel 4.4.0

I found https://www.furorteutonicus.eu/2013/08/04/enabling-host-guest-networking-with-kvm-macvlan-and-macvtap/ which has some addition ip commands that I think are what we are missing, but running ip route flush dev has ended poorly for me in the past, so I’d like some more guidance.