Running Home Assistant with Docker (docker-compose)

Home Assistant on Docker is easier than running it with HASSIO IMO. :rocket:

Here is a high-altitude overview of how I run Home Assistant -and- then I’ll dig into the details of my setup.

Okay, details… here is how I run Home Assistant on Docker on a Raspberry Pi 4.

version: '3.7'
services:
  homeassistant:
    container_name: homeassistant
    image: homeassistant/raspberrypi4-homeassistant:latest
    network_mode: "host"
    ports:
      - "8123:8123"
    volumes:
      - /opt/homeassistant:/config
      - /etc/localtime:/etc/localtime:ro
      - /etc/letsencrypt:/etc/letsencrypt:ro
    devices:
      - /dev/ttyACM0:/dev/ttyACM0:rwm
    restart: always
    healthcheck:
      test: ["CMD", "curl", "-f", "http://127.0.0.1:8123"]
      interval: 30s
      timeout: 10s
      retries: 6
# /etc/systemd/system/home-assistant.service

[Unit]
Description=Home Assistant Service
Requires=docker.service
After=docker.service

[Service]
WorkingDirectory=/root
ExecStart=/usr/local/bin/docker-compose up
ExecStop=/usr/local/bin/docker-compose down
TimeoutStartSec=0
Restart=on-failure
StartLimitIntervalSec=60
StartLimitBurst=3

[Install]
WantedBy=multi-user.target
[ docker home-automation home-assistant ]