balenaOS on RPI 3B+ need to assign docker a macvlan (DHCP) that is visible on local network

I need to create 3 separate docker containers (with alpine) and I need the network interface to be accessible from the local network (same as host, but DHCP and individual interaces on each, not all like when using --net=host) can someone help me accomplish this?

Thanks! :+1:


On my RPI build (Raspbian) I was creating 3 macvlans

ip link add link eth0 name eth0.1 address xx:xx:xx:xx:xx:xx type macvlan
ip link add link eth0 name eth0.2 address xx:xx:xx:xx:xx:xx type macvlan
ip link add link eth0 name eth0.3 address xx:xx:xx:xx:xx:xx type macvlan

But when I created my containers and assiged --net=eth0.0 I get a network not found error.

Hello @edgararroyo

I don’t think that’s how docker’s --net= option works.

I’ve never done this before and I have no idea if it will work. I’m not sure this is supported on Balena.

Docker macvlan docs:
docker-compose networking docs:

a docker-compose.yml file like this might work (not tested):

version: "3"
    build: ./service1
      - network1
    build: ./service2
      - network2
    build: ./service3
      - network3
    driver: macvlan
      parent: "eth0"
    driver: macvlan
      parent: "eth0"
    driver: macvlan
      parent: "eth0"

Thank you for your response. I ended up doing this on Raspbian, but I need a balenaOS solution still.

# Get IPv4 for Gateway, Subnet Mask and IP Addresses
while [ -z “$ip4” ]

ip4="$(ip -o -4 addr list eth0 | awk ‘{print $4}’ | cut -d. -f1,2,3)"

# Create Docker network
docker network create -d macvlan --subnet="$ip4.0/24" --gateway="$ip4.1" -o parent=eth0 \
-o macvlan_mode=bridge eth0

# Run dockers
docker run -d --name=‘alpine1’ --net=‘eth0’ --ip="$ip4.101" ‘alpine’ tail -f /dev/null
docker run -d --name=‘alpine2’ --net=‘eth0’ --ip="$ip4.102" ‘alpine’ tail -f /dev/null
docker run -d --name=‘alpine3’ --net=‘eth0’ --ip="$ip4.103" ‘alpine’ tail -f /dev/null

Problem now is, if I use this RPI on another network that does not use subnet mask 0/24 and/or gateway .1 and/or ip addresses 101 thru 103, this will not work

Can I create a docker network macvlan that uses DHCP?


I have done some quick testing and I do not think the macvlan plugin is supported in balena-engine. I have asked a collegue from the balena-engine team to comment though, as I may be mistaken.

@richbayliss ok, thanks. Also, can you find out if they can add the ipam dhcp driver?

Thanks again.

I don’t think it will be a case of adding them; we deliberately removed the plugin system from moby to reduce on-disk space usage. I am only unsure if this also included macvlan which is what I have asked for clarification of, but I would not expect that it would be desirable to add it back in.

Huh… Ok, thanks.

Hi, I can confirm that macvlan is intentionally removed from balenaEngine

Is it possible to re-add in a custom build @lucianbuzzo ? I have need of it.

Hi there,

If you wish to roll your own version of balenaOS with a patched balenaEngine, you can find instructions on hacking on balenaEngine here ( and building custom images here (

We also offer custom board support plans which may better suit you, you can reach out to our sales folks directly if you are interested (

Thanks. Sorry for not seeing this sooner. I’ll give it a shot. :smiley: