Docker network equivalent of virtual machine bridged network mode

1

1

I want to deploy a Docker container within a network that appears accessible with its own link layer device / MAC address, the equivalent of a virtual machine with a bridged mode network adapter.

In particular, I wish to have both routing to the public internet and private LAN hosts ping capability with this networking arrangement; I can currently achieve this with a virtual machine.

The Docker documentation describes a suitable macvlan network driver type but I have not been able to get the required functionality above working in Docker.

I can ping IP 10.177.202.7 from the host but this fails from within the container. These are the commands and output from my host and container (edited for brevity):

# get required subnet detail
ip a s wlp4s0
3: wlp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:cc:f8:66:a3:42 brd ff:ff:ff:ff:ff:ff
    inet 10.177.202.159/24 brd 10.177.202.255 scope global dynamic noprefixroute wlp4s0
       valid_lft 2371sec preferred_lft 2371sec

# get gateway
ip r 
default via 10.177.202.1 dev wlp4s0 proto dhcp metric 600

# using the subnet and gateway info to create Docker macvlan
sudo docker network create -d macvlan --subnet='10.177.202.0/24' --gateway='10.177.202.1' -o parent='wlp4s0' macvlan_test
sudo docker run --network macvlan_test -it ubuntu bash

# 
# within container from here
#

root@d98d8b305ec7:/data# ip a s
191: eth0@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:0a:b1:ca:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.177.202.2/24 brd 10.177.202.255 scope global eth0
       valid_lft forever preferred_lft forever
root@d98d8b305ec7:/data# ping 10.177.202.7
PING 10.177.202.7 (10.177.202.7) 56(84) bytes of data.
^C
--- 10.177.202.7 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2041ms
root@c212f3c26858:/data# ip r
default via 10.177.202.1 dev eth0 
10.177.202.0/24 dev eth0 proto kernel scope link src 10.177.202.2 

Any thoughts on what I am missing would be greatly appreciated.

user1330734

Posted 2020-01-15T00:20:27.247

Reputation: 231

No answers