Docker Community Forums

Share and learn in the Docker community.

Help with docker compose network settings for getting a DHCP address from my LAN

how can i build a docker using docker-compose to get a dedicated IP from my DHCP server in the LAN. I have the following code working on my NAS, but i need to migrate to an ubuntu 20.04 that doesnt have the “qnet” driver. Any ideas on how to do this with macvlan or other solution? Note that i am looking for the following:

Specify a predefined MAC address, so the my DHCP server from the LAN will assign a specific IP that i have it reserved for.

The following file is how i have it in my QNAP NAS. I need to update the network settings to something that works on a ubuntu server.

version: '2.4'
services:
  mqtt:
    container_name: eclipse-mosquitto-cli
    image: eclipse-mosquitto:latest
    volumes:
        - /LinuxContainers/eclipse-mqtt:/mosquitto/config
    environment:
      - TZ=America/Los_Angeles
    restart: always
    mac_address: 02:ff:0a:fa:1a:b2
    networks:
      - qnet-dhcp
    hostname: mosquitto

networks:
  qnet-dhcp:
    driver: qnet
    ipam:
      driver: qnet
      options:
        iface: "eth0"