Docker Community Forums

Share and learn in the Docker community.

Make container launched with macvlan network to connect to public network


(Mohanestack) #1


As obvious container launched with bridged network connects to public network and works fine.

My query - Is it possible to make the container launched with macvlan network connect to public network.

Below are the steps I followed.

Launch container with default bridge nw.
docker run --rm -dit --name=alpine-bridge alpine ash

ping google for public connectivity
docker exec alpine-bridge ping -c 2

PING ( 56 data bytes
64 bytes from seq=0 ttl=51 time=187.768 ms
64 bytes from seq=1 ttl=51 time=146.569 ms ping statistics —
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 146.569/167.168/187.768 ms

Host ifconfig command output
My host system connected to a wifi network

inet netmask broadcast
inet6 fe80::f72a:652a:147d:7745 prefixlen 64 scopeid 0x20
ether 08:d4:0c:09:56:dc txqueuelen 1000 (Ethernet)
RX packets 250614 bytes 156122122 (156.1 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 250819 bytes 60919158 (60.9 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Created a macvlan network with parent as wlp3s0
docker network create -d macvlan --subnet= --gateway= -o parent=wlp3s0 pub-net

Launch container with bridged Network
docker run --rm -dit --network=pub-net --name=alpine-mac alpine ash

connectivity not works with this setup
docker exec alpine-mac ping -c 2

ping is not working.

Docker inspect for macvlan network
“Name”: “pub-net”,
“Id”: “c235ebfe22968f044420b1a9a9fb883395fe66de6e66df457d0c692472d63088”,
“Created”: “2018-11-16T13:32:01.811456245+05:30”,
“Scope”: “local”,
“Driver”: “macvlan”,
“EnableIPv6”: false,
“IPAM”: {
“Driver”: “default”,
“Options”: {},
“Config”: [
“Subnet”: “”,
“Gateway”: “”
“Internal”: false,
“Attachable”: false,
“Ingress”: false,
“ConfigFrom”: {
“Network”: “”
“ConfigOnly”: false,
“Containers”: {
“d0473232409f748e8980f52350f24ffc12f390c7eadebb9a41c2943fc6a5e42b”: {
“Name”: “alpine-mac”,
“EndpointID”: “22bb289f706c047748f980310bdf7d381b5cc948c66665303e9435ba3d1fba99”,
“MacAddress”: “02:42:c0:a8:0f:02”,
“IPv4Address”: “”,
“IPv6Address”: “”
“Options”: {
“parent”: “wlp3s0”
“Labels”: {}

How this issue can be addressed?

Thanks and Regards,