Docker and Kitematic vs docker-compose

I’ve been able to install HA on my Docker for Windows using Kitematic. However when my host machine running docker reboots, I want the home-assistant container to start.

  1. Does anyone know how Kitematic installs home-assistant? Is there a docker file or a docker compose that it uses? I’m desperately trying to find out what commands it’s using to set things up, as it’s not doing things exactly as I’d prefer. Do you know who the person(s) responsible for publishing HA to the docker hub?

  2. Kitematic notwithstanding, after some research, I think I may want to use docker-compose to install HA because I’ll want to start some other containers, such as MQTT. Does anyone have a sample they can provide? I’d like to be able to not only to get HA installed, but

  1. Specify the ports, e.g. 8123:8123
  2. Set the configuration directory, e.g. c:\mystuff\HAConfig:config
  3. Specify the restart policy so that the container always starts when the Docker for Windows restarts

Look for My Docker Stack here in the forum.

1 Like

@flamingm0e why does your homeassistant section depend on influx and postdb1?

Doesn’t HA use its own internal database?

volumes:
      - /srv/docker/hass-config:/config
      - /etc/localtime:/etc/localtime:ro
      - /srv/docker/hass_media:/media 

What is the media mapping for?
What is /etc/localtime for? Time zone? Do you know if there is a windows equivalent?

Are you missing a port mapping for homeassistant?

Because I use postgresql for my database

Yeah, if you don’t specify one, it will use it’s own. I find it’s own to be quite lacking for me to access and manipulate data.

for dropping media files into (custom wav/mp3 for HA to play through the google homes)

it’s for making sure my docker containers run the correct time/timezone
There is nothing in Windows I am aware of…Just know that if you use ‘Docker on Windows’ it is technically running INSIDE an Ubuntu VM.

no.

network_mode: host

What does this do? The default port is 8123. Does docker-compose know home assistant uses this port and just maps all calls to localhost:8123 to this container on 8123? The documentation is a bit unclear. What happens if you have two services using the same port?

It says, whatever port the application in the docker container needs it is exposed. It has nothing to do with docker compose directly. It’s a docker network model.

The second application that is requesting that port just fails to start because it cannot listen on that port.

How does docker know the port the service uses? Is there a docker file that has this information? Just trying to understand how docker does things.

The application inside the container has access to any port that a service isn’t running on already. It has full network access to the host. Docker doesn’t care, and it’s not “mapped”. It’s just passed through as it needs.

Ah. So if I were running IIS it wouldn’t allow port 80 through. Starting to make sense. Does this mean docker does a port scan on the host to see what ports are in use already?

Not really. It’s more like the application inside docker image/container asks to bind to a port, if the port is already in use, it just errors out. It doesn’t actively scan for open porta or anything

homeassistant:
    container_name: home-assistant
    restart: unless-stopped
    image: homeassistant/home-assistant
    depends_on:
      - "influxdb"
      - "postdb1"
    devices:
      - /dev/ttyACM0:/dev/ttyACM0
    volumes:
      - /srv/docker/hass-config:/config
      - /etc/localtime:/etc/localtime:ro
      - /srv/docker/hass_media:/media
    network_mode: host
    privileged: true

How does the homeassistant container know what database to use for storage? The depends_on merely say that container is required, not what it’s used for. Is there a setting in configuration.yaml which handles this?

Docker has nothing to do with the configuration inside Home Assistant.

Correct. I want my postgresql database running before Home Assistant starts.