Compose - Home assistant not working

I am using docker-compose to create a home assistant configuration which includes zigbee2mqtt and mosquitto. I’d like to automate all if possible, so I can recreated if needed. although i don’t know how to create the configuration files. Is there a way to fully script the deployment of these apps ? I use the script below.

homeassistant:
    container_name: homeassistant
    image: homeassistant/home-assistant:latest
    volumes:
      - $DOCKERDIR/homeassistant:/config
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped
    privileged: true
    ports:
      - '8123:8123'
#Mosquitto
  mosquitto:
    container_name: mqtt
    image: eclipse-mosquitto
    ports:
      - '1883:1883'
    # This port is for Webhooks
      - '9001:9001'
    volumes:
      - $DOCKERDIR/mosquitto/config:/mosquitto/config
      - $DOCKERDIR/mosquitto/data:/mosquitto/data
      - $DOCKERDIR/mosquitto/log:/mosquitto/log
#Zigbee2MQTT
  zigbee2mqtt:
    container_name: zigbee2mqtt
    depends_on:
      - mosquitto
    image: koenkk/zigbee2mqtt
    volumes:
      - $DOCKERDIR/zigbee2mqtt/data:/app/data
      - /run/udev:/run/udev:ro
    ports:
    # Frontend port
      - '8180:8080'
    devices:
      - '/dev/ttyUSB0:/dev/ttyUSB0'
    restart: always
    privileged: true

Yes, it is possible to fully automate the deployment of applications using Docker Compose and configuration files.

To do this, you can create a docker-compose.yml file that defines the services you want to deploy, along with any necessary configuration options. The docker-compose.yml file should specify the images you want to use for each service, as well as any volumes, networks, and environment variables that are needed.

I am trying to understand the question. Docker Compose will not create the configuration files. Only you know how you want to configure your applications, but you can mount the configuations files and you have mounted folders so I guess you know how to mount them. If you are using some kind of web admin interface which expects existing files, you need to create them first. If you can’t do that because you don’t have permission to log in to the host, you can create the configuration files on your machine, build a new image, push it to a registry and use that image in the compose file. You can also create a custom entrypoint to generate the config files from a template when the container starts and store the values in environment variables.

Hi @piet200,

you are just a couple of steps ahead of me. :slight_smile:

Your yaml will create 3 containers (HomeAssistant, Mosquitto for mqtt and Zigbee2mqtt), but you still have to manually configure settings in each of the applications.

I am not using zigbee. Is your question about integrating the usb-dongle? You should be able to integrate it directly into HomeAssistant: Living without add-ons on Home Assistant Container - YouTube

@rimelek: If I understand piet200 correctly, he has to do some configuration within HomeAssistant, such as adding the IP-address and ports of the mqtt-server (-> mosquitto). From my Graylog-tests, I know, that you can provide configuration settings in a compose.yaml by using the “environment”-tag, but this seems rather application specific? Is there a general documentation on this? Is this something that has to be provided by the application provider (-> e.g. HomeAssistant)?

What do you mean by “application specific”? You can use environment variables in any containers. The maintainer of the image should document the variables that the image supports. You cna also create your own image and define your own variables for your entrypoint which generates configuration files if the application itself doesn’t support variables, only configuration files.

If home assistent has a special admin interface that doesn’t allow you to define usual compose files, then yes, the developers of that app should document how it supports definining environment variables…

That’s what I mean by application specific. :slight_smile:

@piet200, did you find what you were asking for? I would very much appreciate, if you could share your findings. :slight_smile:

Chris

@piet200,
I just did a little search in the HA-forum and found some posts, which are going into your direction. This might be of value to you (and soon to me)

1 Like