dockermacvlan

Docker network macvlan driver: gateway unreachable


I have a macvlan network created with the following command:

docker network create -d macvlan --subnet=192.168.1.0/24  --gateway=192.168.1.2  -o parent=wlp2s0 pub_ne 

Where wlp2s0 is the name of the wireless interface of my laptop. gateway is 192.168.1.1 and subnet 192.168.1.0/24

Then I have created and attached a container to this network:

docker run --rm -itd  --network pub_ne  --name myAlpine alpine:latest  sh

In addition I have created a virtual machine using, virtualbox provider, with bridged network interface.

if I use ping command: - docker container -> vm ubuntu (ip of vm: 192.168.1.200) : ping works

but if I use ping command: - docker container -> gateway 192.168.1.1 or - docker container -> external world (google.com): ping not works

suggestions?

edit 1:

On docker host if i run tcpdump ( tcpdump -i icmp ) i see:

    14:53:30.015822 IP 192.168.1.56 > 216.58.205.142: ICMP echo request, id 5376, seq 29, length 64
14:53:31.016143 IP 192.168.1.56 > 216.58.205.142: ICMP echo request, id 5376, seq 30, length 64
14:53:32.016426 IP 192.168.1.56 > 216.58.205.142: ICMP echo request, id 5376, seq 31, length 64
14:53:33.016722 IP 192.168.1.56 > 216.58.205.142: ICMP echo request, id 5376, seq 32, length 64

Where 192.168.1.56 is my docker container and 216.58.205.142 should be google ip address. No echo reply is received.


Solution

  • Macvlan is unlikely to work with IEEE 802.11.

    Your wifi access point, and/or your host network stack, are not going to be thrilled.

    You might want to try ipvlan instead: add -o ipvlan_mode=l2 to your network creation call and see if that helps.

    That might very well still not work... (for eg, if you rely on DHCP and your DHCP server uses macaddresses and not client id)

    And your only (reasonable) solution might be to drop the wifi entirely and wire the device up instead... (or move away from macvlan and use host / bridge - whichever is the most convenient)