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

**URL:** <https://forums.balena.io/t/balenaos-on-rpi-3b-need-to-assign-docker-a-macvlan-dhcp-that-is-visible-on-local-network/31922>\
**Category:** balenaOS\
**Tags:** raspberrypi3\
**Created:** [September 11, 2019, 2:25pm UTC](https://forums.balena.io/t/balenaos-on-rpi-3b-need-to-assign-docker-a-macvlan-dhcp-that-is-visible-on-local-network/31922 "2019-09-11T14:25:30Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![edgararroyo](https://avatars.discourse-cdn.com/v4/letter/e/779978/32.png) [@edgararroyo](https://forums.balena.io/u/edgararroyo)\
**Post date:** [September 11, 2019, 2:25pm UTC](https://forums.balena.io/t/balenaos-on-rpi-3b-need-to-assign-docker-a-macvlan-dhcp-that-is-visible-on-local-network/31922/1 "2019-09-11T14:25:30Z")

</div>

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! 👍

EDIT:

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.

---

<div class="post-metadata">

**Author:** ![zvin](https://avatars.discourse-cdn.com/v4/letter/z/a5b964/32.png) [@zvin](https://forums.balena.io/u/zvin)\
**Post date:** [September 11, 2019, 5:36pm UTC](https://forums.balena.io/t/balenaos-on-rpi-3b-need-to-assign-docker-a-macvlan-dhcp-that-is-visible-on-local-network/31922/2 "2019-09-11T17:36:20Z")

</div>

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: [https://docs.docker.com/v17.09/engine/userguide/networking/get-started-macvlan/](https://docs.docker.com/v17.09/engine/userguide/networking/get-started-macvlan/)  
docker-compose networking docs: [https://docs.docker.com/compose/networking/](https://docs.docker.com/compose/networking/)

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

```auto
version: "3"
services:
  service1:
    build: ./service1
    networks:
      - network1
  service2:
    build: ./service2
    networks:
      - network2
  service3:
    build: ./service3
    networks:
      - network3
networks:
  network1:
    driver: macvlan
    driver_opts:
      parent: "eth0"
  network2:
    driver: macvlan
    driver_opts:
      parent: "eth0"
  network3:
    driver: macvlan
    driver_opts:
      parent: "eth0"

```

---

<div class="post-metadata">

**Author:** ![edgararroyo](https://avatars.discourse-cdn.com/v4/letter/e/779978/32.png) [@edgararroyo](https://forums.balena.io/u/edgararroyo)\
**Post date:** [September 11, 2019, 7:29pm UTC](https://forums.balena.io/t/balenaos-on-rpi-3b-need-to-assign-docker-a-macvlan-dhcp-that-is-visible-on-local-network/31922/7 "2019-09-11T19:29:15Z")

</div>

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”]
> 
> do  
> ip4=“$(ip -o -4 addr list eth0 | awk ‘{print $4}’ | cut -d. -f1,2,3)”  
> done
> 
> # 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?

---

<div class="post-metadata">

**Author:** ![richbayliss](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/richbayliss/32/1054_2.png) [@richbayliss](https://forums.balena.io/u/richbayliss)\
**Post date:** [September 11, 2019, 8:45pm UTC](https://forums.balena.io/t/balenaos-on-rpi-3b-need-to-assign-docker-a-macvlan-dhcp-that-is-visible-on-local-network/31922/8 "2019-09-11T20:45:17Z")

</div>

Hi,

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.

---

<div class="post-metadata">

**Author:** ![edgararroyo](https://avatars.discourse-cdn.com/v4/letter/e/779978/32.png) [@edgararroyo](https://forums.balena.io/u/edgararroyo)\
**Post date:** [September 11, 2019, 9:02pm UTC](https://forums.balena.io/t/balenaos-on-rpi-3b-need-to-assign-docker-a-macvlan-dhcp-that-is-visible-on-local-network/31922/18 "2019-09-11T21:02:19Z")

</div>

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

Thanks again.

---

<div class="post-metadata">

**Author:** ![richbayliss](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/richbayliss/32/1054_2.png) [@richbayliss](https://forums.balena.io/u/richbayliss)\
**Post date:** [September 11, 2019, 9:05pm UTC](https://forums.balena.io/t/balenaos-on-rpi-3b-need-to-assign-docker-a-macvlan-dhcp-that-is-visible-on-local-network/31922/19 "2019-09-11T21:05:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![edgararroyo](https://avatars.discourse-cdn.com/v4/letter/e/779978/32.png) [@edgararroyo](https://forums.balena.io/u/edgararroyo)\
**Post date:** [September 11, 2019, 9:42pm UTC](https://forums.balena.io/t/balenaos-on-rpi-3b-need-to-assign-docker-a-macvlan-dhcp-that-is-visible-on-local-network/31922/21 "2019-09-11T21:42:54Z")

</div>

Huh… Ok, thanks.

---

<div class="post-metadata">

**Author:** ![lucianbuzzo](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/lucianbuzzo/32/615_2.png) [@lucianbuzzo](https://forums.balena.io/u/lucianbuzzo)\
**Post date:** [September 16, 2019, 10:14am UTC](https://forums.balena.io/t/balenaos-on-rpi-3b-need-to-assign-docker-a-macvlan-dhcp-that-is-visible-on-local-network/31922/26 "2019-09-16T10:14:15Z")

</div>

Hi, I can confirm that `macvlan` is intentionally removed from balenaEngine [https://github.com/balena-os/balena-libnetwork/commit/9e7c869176ffe3131c65506747e361d6ba7ca2de](https://github.com/balena-os/balena-libnetwork/commit/9e7c869176ffe3131c65506747e361d6ba7ca2de)

---

<div class="post-metadata">

**Author:** ![vesper](https://avatars.discourse-cdn.com/v4/letter/v/c68b51/32.png) [@vesper](https://forums.balena.io/u/vesper)\
**Post date:** [October 9, 2019, 4:05pm UTC](https://forums.balena.io/t/balenaos-on-rpi-3b-need-to-assign-docker-a-macvlan-dhcp-that-is-visible-on-local-network/31922/28 "2019-10-09T16:05:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![xginn8](https://avatars.discourse-cdn.com/v4/letter/x/8baadc/32.png) [@xginn8](https://forums.balena.io/u/xginn8)\
**Post date:** [October 9, 2019, 5:59pm UTC](https://forums.balena.io/t/balenaos-on-rpi-3b-need-to-assign-docker-a-macvlan-dhcp-that-is-visible-on-local-network/31922/31 "2019-10-09T17:59:52Z")

</div>

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 ([https://github.com/balena-os/balena-engine/tree/master/hack](https://github.com/balena-os/balena-engine/tree/master/hack)) and building custom images here ([https://www.balena.io/os/docs/custom-build/](https://www.balena.io/os/docs/custom-build/)).

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 ([https://www.balena.io/contact-sales](https://www.balena.io/contact-sales)).

---

<div class="post-metadata">

**Author:** ![vesper](https://avatars.discourse-cdn.com/v4/letter/v/c68b51/32.png) [@vesper](https://forums.balena.io/u/vesper)\
**Post date:** [November 4, 2019, 3:28pm UTC](https://forums.balena.io/t/balenaos-on-rpi-3b-need-to-assign-docker-a-macvlan-dhcp-that-is-visible-on-local-network/31922/36 "2019-11-04T15:28:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Olivia](https://avatars.discourse-cdn.com/v4/letter/o/b9e5f3/32.png) [@Olivia](https://forums.balena.io/u/Olivia)\
**Post date:** [February 13, 2020, 10:05pm UTC](https://forums.balena.io/t/balenaos-on-rpi-3b-need-to-assign-docker-a-macvlan-dhcp-that-is-visible-on-local-network/31922/37 "2020-02-13T22:05:02Z")

</div>

Hi guys, I came to this thread when I was looking about macvlan support on BalenaOS.  
Has this situation changed in the past few months or there are still no plans for this plugin to be already baked in on the images that Balena provides?  
Thanks!

---

<div class="post-metadata">

**Author:** ![AlidaOdendaal](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/alidaodendaal/32/1641_2.png) [@AlidaOdendaal](https://forums.balena.io/u/AlidaOdendaal)\
**Post date:** [February 17, 2020, 8:13am UTC](https://forums.balena.io/t/balenaos-on-rpi-3b-need-to-assign-docker-a-macvlan-dhcp-that-is-visible-on-local-network/31922/42 "2020-02-17T08:13:14Z")

</div>

Hi @Olivia

Welcome to forums!

The situation is still the same, there are unfortunately no plans at this stage for adding macvlan to balenaEngine.

Kind regards  
Alida
