Docker Community Forums

Share and learn in the Docker community.

Extend compose file, add to existing network

I have a docker-compose file (see below) to create 2 containers, mosquitto and zigbee2mqtt.
I have a few questions as I want to automate some more tasks.

  1. I have a custom network in my docker environment and want both containers to be connected to that network,

  2. I’d like to use authentication for Mosquitto, can this be done by this docker-compose file ? what would be the easiest way to achieve this ?

  3. The container installation of zigbee2mqtt creates a config file “configuration.yaml”
    Would it be possible to automate a change of this configuration file once it is created the configuration file point to localhost as mqtt server, but this needs to be adjusted to mqtt.

version: '3.8'
    image: eclipse-mosquitto:2.0
    hostname: mqtt
    container_name: mqtt
    restart: always
      - "./mosquitto-data:/mosquitto"
      - "1883:1883"
      - "9001:9001"
    command: "mosquitto -c /mosquitto-no-auth.conf"

    container_name: zigbee2mqtt
    hostname: zigbee2mqtt
    container_name: zigbee2mqtt
    image: koenkk/zigbee2mqtt
      - ./data:/app/data
      - "8081:8081"
      # CC251
      #- /dev/ttyUSB_cc2531:/dev/ttyACM0
      # CC2530 / GBAN GB2530S
      - /dev/ttyACM0:/dev/ttyACM0
    restart: always