After trying for days I hope someone can help me out over here.

I would like to connect a docker to the secondary IP on my virtual host, where the applications in the docker use eth0.

The good news is that a ping outside my docker to the secondary IP works (‘ping -I’).

I’ve setup a user network (macvlan) as well using:
docker network create -d macvlan --subnet= --gateway= my-macvlan-net

PS: I’m not completely sure about the gateway, but I used extension 254 because my main IP uses the same gateway, and if I ommit this parameter it is set to extension 1, which doesn’t work either.

Then I connected via:

docker run --rm -dit --network my-macvlan-net --name my-macvlan-alpine --ip alpine:latest ash

Now a ping to Google from within the docker yields:
ping: bad address ‘

(note that a ping to an existing IP just doesn’t give data back)

An ‘ip a’ from within the docker gives:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet scope host lo
valid_lft forever preferred_lft forever
117: eth0@if116: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP
link/ether 02:42:6d:ed:d8:f0 brd ff:ff:ff:ff:ff:ff
inet brd scope global eth0
valid_lft forever preferred_lft forever

And an ‘ip route’ from within the docker gives:
default via dev eth0 dev eth0 scope link src

Any tips to help me out?