Docker Community Forums

Share and learn in the Docker community.

Cannot connect to gateway using macvlan network

(Kasia) #1

I have two docker hosts (VMware virtual machines) connected to one vlan. Gateway is xx.xx.xx.1, first VM has address xx.xx.xx.3 and second xx.xx.xx.4. On each host I create macvlan network:
docker network create -d macvlan --subnet=xx.xx.xx.0/24 --gateway=xx.xx.xx.1 -o parent=ens192 mcv
I cannot ping from host to container and form container to its host, but I can ping two conrainers running on the same host in macvlan network. When I trying to ping the gateway the result is it is unreachable.

Route command inside a container:

Destination Gateway Genmask Flags Metric Ref Use Iface
default xx.xx.xx.1 UG 0 0 0 eth0
xx.xx.xx.0 * U 0 0 0 eth0

Expected result:
New containers get IP from my VLAN but they should connect between two hosts and the Internet.

Maybe someone has an idea how fix or do it in different way.

Output of docker version:

Version: 1.12.0
API version: 1.24
Go version: go1.6.3
Git commit: 8eab29e

OS/Arch: linux/amd64

Version: 1.12.0
API version: 1.24
Go version: go1.6.3
Git commit: 8eab29e

OS/Arch: linux/amd64

(Docker2014) #2

I have the same proble can someone please help us ?

(marco) #3

I also have the same problem. I tried with and without promiscuous mode (VMware network), but both modes are not working with macvlan driver. Using inside VM vmxnet3.
I have opened a service request at VMware and I was told that’s a docker driver problem.

(Srzjulio) #4

Was there ever a solution to this? I have the same problem. I also tried exposing ports in the Docker run command line for each container, but that doesn’t work.

(Sreenivas Makam) #5

Pls check if this helps( Host cannot directly talk to container in macvlan network unless macvlan interface is created on host as well. I got this working with virtualbox, there could be some specifics with vmware.

(Srzjulio) #6

The link doesn’t exactly talk about getting host to container communication working. I do have a macvlan interface on the host as well.

What I’m trying to do is have a container appear as a physical machine on the network. I figured what I could do is create a macvlan interface on the host. Spin up my container, and then have the container use this macvlan interface for traffic to the outside world. This is mostly for some experimentation we’re doing.

Not sure if that is realistic or now though.

(Sreenivas Makam) #7

Yes, the only way for host to talk to containers in macvlan network is to create macvlan interface on the host. The details were in the Q&A section of blog. I have moved that to 1 of the sections in the blog now for easier reference.

(Josephlim75) #8

Hi Sreenivas,

Everything seems to work. The only problem I had is the container is not able to connect its own host ip address. It can connect to a remote host but not its own host.

I have post detail information at

(Goeland86) #9

So, I’m in the situation where my containers on the macvlan are pingable from the network, and I can ping machines back. However I can’t seem to ping the gateway.

Any ideas why that would be? I’ve read through Sreenivas’s post but can’t make sense of where I go wrong.

situation: network is - host is, GW is Gateway can be pinged from the host.

$ docker network create -d macvlan --subnet= --ip-range --gateway= -o parent=ens1 my_macvlan
$ docker run --rm -it --network=my_macvlan alpine /bin/sh
#/ ping -c 3 10.x.x.x 

<works, where x.x.x is a physical host on the network>

#/ ping -c 3
PING ( 56 data bytes

--- ping statistics ---
3 packets transmitted, 0 packets received, 100% packet loss

Any help is much appreciated - I have been banging my head on the problem for too long now.