Skip to main content

Setting up Home Assistant in Docker

Home Assistant is the backbone of my Smart Home, there are a number of ways to install it. Most recommend to install Home Assistant OS which is a linux install with the home assistant software and a supervisor to manage add-ons. In practice the supervisor manages the containers that make up the add-ons

My preferred method is the container version which is a docker container, this gives us complete control over the installation and allows us to use the server/VM for other apps if desired. In this set up we effectively take on the role of the supervisor, and can install add-ons manually as separate docker containers.

Docker can run on as little as a raspberry pi, but note this can lead to quickly burning through SD cards due to the frequent read/writes from the database.

I have my HA installed in an Ubuntu Server VM, this guide assumes there is already a suitable Linux environment set up (Either in a VM or bare metal).

 

Step 1 - Install docker and docker-compose

sudo apt update
sudo apt upgrade
sudo apt install docker docker-compose -y

This will install docker engine, compose, and all required components

 

Step 2 - Create docker-compose and start container

I like to use VScode over SSH to manage the docker-compose files, as it is much easier to identify formatting errors and manage multiple .yaml files.

Create a new file in the home directory (or wherever you wish to set up Home Assistant) called docker-compose.yml

version: '3'
services:
  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:latest"
    restart: unless-stopped
    environment:
      - TZ=Europe/Dublin
    volumes:
      - ./HA:/config
      - /etc/localtime:/etc/localtime:ro
    network_mode: host
    privileged: true

Note: ./HA is where all Home Assistant config files will go, it can be changed to wherever you wish.

Save the file and from the terminal run

docker-compose up -d

NOTE: If you get an error either run the command as sudo or follow instructions here to run docker commands as root.

Docker will download the latest image and start the container

image.png

Once the container is running, the interface will be accessible from http://<server IP address>:8123

image.png

Step 3 - Onboard (or restore from backup)

If you have a backup to restore, you can restore the Home Assistant data folder now (be sure to stop the container first)
Otherwise continue with onboarding which is covered in the Home Assistant docs here.