By now a lot of people have heard of Home Assistant and also of Docker. Both looked a bit intimidating to me when I first looked at them, so, how do we set up Home Assistant with Docker? There is quite some documentation available at home-assistant.io but they assume you already have Docker running. Lets do a step-by-step tutorial.
To install Home Assisant, first get yourself a system compatible of running Docker (I’m running Ubuntu Server 18.04) and install Docker (for a more detailed Docker how-to: Blogpost)
apt install docker.io -y
Because we’re going to use docker-compose, we install this too. Go to https://github.com/docker/compose/releases and check what the latest version is. At this moment it’s 1.21.2 so we’re gonna go with that version.
curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose
You can check for the docker-compose version via the commandline, using
docker-compose --version. You should see something like
docker-compose version 1.21.2, build a133471
Next we’re going to create a folder on the server where the Docker container of Home Assistant is writing all of it’s files to and where we can configure Home Assistant. This way, when you recreate the container you won’t lose all your settings.
mkdir -p /home/docker/homeassistant
In this folder, we also create the docker-compose.yml file which is the configuration for the Docker container when you start it.
cat > /home/docker/homeassistant/docker-compose.yml << EOF version: '3' services: ha: image: homeassistant/home-assistant restart: always network_mode: host # ports: # - 8123:8123/tcp volumes: - ./config:/config EOF
Now all that is left, is to start the Docker container
docker-compose -f /home/docker/homeassistant/docker-compose.yml up -d
As soon as you see
Creating homeassistant_ha_1 ... done, you can open Home Assistant in your browser via http://server-ip:8123