Docker VM macvlan unable to reach host even with host macvlan interface

91 views Asked by At

I setup docker running in alpine VM on proxmox host. In the docker VM, I created a docker macvlan and ran into the problem of the containers not being able to contact the host.

I read Docker Macvlan network inside container is not reaching to its own host and followed the workaround mentioned at https://blog.oddbit.com/post/2018-03-12-using-docker-macvlan-networks. However the container still cannot reach the host when trying to ping in the console. The container and host can reach internet and other computers fine.

Would appreciate any help for figuring this out. Would running in the VM, which probably already uses a macvlan affect this?

Docker network I made:

docker network create \
  -d macvlan \
  --attachable \
  -o macvlan_mode=bridge \
  -o parent=eth0 \
  --subnet=10.0.0.0/16 \
  --ip-range=10.0.4.0/24 \
  --gateway=10.0.1.1 \
  --aux-address="host=10.0.4.0" \
  macvlan

The macvlan network interface I added:

ip link add docker-shim link eth0 type macvlan mode bridge
ip addr add 10.0.4.0/32 dev docker-shim
ip link set docker-shim up
ip route add 10.0.4.0/24 dev docker-shim

ip addr relevant output:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether ba:5e:df:f6:76:e9 brd ff:ff:ff:ff:ff:ff
    inet 10.0.1.5/16 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fd66:e56d:bb25:b18f:b85e:dfff:fef6:76e9/64 scope global dynamic flags 100
       valid_lft 1789sec preferred_lft 1789sec
    inet6 fe80::b85e:dfff:fef6:76e9/64 scope link
       valid_lft forever preferred_lft forever

...

24: docker-shim@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
    link/ether 5e:b2:c8:7a:ad:d1 brd ff:ff:ff:ff:ff:ff
    inet 10.0.4.0/32 scope global docker-shim
       valid_lft forever preferred_lft forever
    inet6 fd66:e56d:bb25:b18f:539d:b154:1f4e:91bd/64 scope global secondary dynamic
       valid_lft 1789sec preferred_lft 1789sec
    inet6 fd66:e56d:bb25:b18f:5cb2:c8ff:fe7a:add1/64 scope global dynamic flags 100
       valid_lft 1789sec preferred_lft 1789sec
    inet6 fe80::5cb2:c8ff:fe7a:add1/64 scope link
       valid_lft forever preferred_lft forever

ip route output:

default via 10.0.1.1 dev eth0  metric 202
10.0.0.0/16 dev eth0 scope link  src 10.0.1.5
10.0.4.0/24 dev docker-shim scope link
10.111.0.0/24 dev docker0 scope link  src 10.111.0.1
172.17.0.0/16 dev docker_gwbridge scope link  src 172.17.0.1
172.18.0.0/16 dev br-8a926078ea41 scope link  src 172.18.0.1

Container has ip of 10.0.4.1. traceroute 10.0.4.1 output:

traceroute to 10.0.4.1 (10.0.4.1), 30 hops max, 46 byte packets
 1  10.0.4.0 (10.0.4.0)  3142.607 ms !H  3130.841 ms !H  3119.932 ms !H
0

There are 0 answers