Docker Community Forums

Share and learn in the Docker community.

Use a MacVlan in a docker-compose

Dear all

I’m a newbee with Docker and I need your help.

I use Portainer to manage my docker images but I would like to use MacVlan to be able to have a specific IP address for each container.

In portainer I created a MacVlan (MacVlan_Config and MacVlan_My) but I don’t know how to use it in a docker compose… (in fact in a portainer stack).

I tried something like this:

    version: "2"
services:
  pihole:
    container_name: "pihole"
    image: pihole/pihole:latest
    volumes:
      - /srv/dev-disk-by-label-Media/AppData/Pi-Hole/etc-pihole/:/etc/pihole/
      - /srv/dev-disk-by-label-Media/AppData/Pi-Hole/etc-dnsmasq.d/:/etc/dnsmasq.d/
    environment:
      - TZ=Europe/Paris
      - WEBPASSWORD= "MYPASSWORD"
    dns:
      - 127.0.0.1
      - 1.1.1.1
    restart: always
  
  networks:
    MacVlan_My:
      external: true
      ipv4_address: 10.10.70.102

Could someone help me?