Network routing for docker container using macvlan

2.2k Views Asked by At

TLDR; I cannot ping my docker containers from my other network clients. Only when a container actively pings the gateway I am able to reach the containers afterwards.

On my homenetwork (192.168.0.0/24) I run a gateway 192.168.0.1 which hosts a DNS server and also routes the internet traffic. My docker host (192.168.0.100) has a macvlan network, created with

docker network create -d macvlan --subnet=192.168.0.0/24 --gateway=192.168.0.100 -o parent=eth0 dockernet

My containers now do get static IPs, like 192.168.0.200. The containers can actively ping other physical hosts on the network, so that works fine.

But if I spin up a new container, it cannot be pinged from my physical network. Not from the docker host (which is expected as this seems to be a limitation of the macvlan network), nor from the gateway or any other client. Once the container actively pings the gateway, it gets also reachable for other clients.

So I guess some routing needs to be done and there I need your help.

Clients run on debian buster and I use an unmanaged switch to connect the clients.

2

There are 2 best solutions below

0
On

I have a very similar situation to yours, so maybe this can help.
However I set up a new docker network as ipvlan and everything worked out of the box.

I am running a Jellyfin container running on a static IP, instead of having it running as host.

0
On

The missing information above was that I am running docker on raspbian. So this question is actually a duplicate of Docker MACVLAN only works Outbound

runsudo rpi-update on the host to make it work