Home Assistant in Docker (Ubuntu 16.04)

Robert Andresen Home Assistant, Internet of things, Tutorials Leave a Comment

After problem upgrading to v0.65, I moved my Home Assistant (HA) to docker. Trying to upgrade in virtual environment (VE) was giving an error message that i needed Python 3.5.3.

I don’t have any experience with docker, beside setting up influxdb and grafana from this guide: https://philhawthorne.com/getting-started-with-grafana-influxdb-for-home-assistant/.

I’m currently running HA on Ubuntu 16.04.

I started reading some docs as my docker experience is close to zero. The docs was very easy to read, so I recommend taking a look at them first or if you are stuck.

Portainer

I use Portainer as an admin-panel to docker. I used Portainer to start HA after setting up the composer file. See https://portainer.io/install.html.

Create docker compose file

After running HA in VE, my HA config is located in /home/homeassistant/.homeassistant. I created a new file in the same directory, called docker-compose.yml, with this content:

You need to change the config-path under volumes to your own, and map any devices you might have.

Install docker-composer

Follow this guide: https://docs.docker.com/compose/install/#install-compose, to install the newest version.

You can check if you have docker-composer installed and which version by running:
# docker-compose –version

I used this command to install it:
# sudo curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-uname -suname -m -o /usr/local/bin/docker-compose

Then set the correct permission:
# chmod +x /usr/local/bin/docker-compose

Test docker compose file

In the directory /home/homeassistant/.homeassistant run the command:
# docker-compose up

You can use the «-d» flag to compose the container in the background, like:
# docker-compose up -d

If you don’t use the -d flag, it will start the container and run it from the console, and give you some output like this:

After testing that HA was working, I pressed CTRL+C to exist the container.

Then I started it with Portainer.

Update Home Assistant

When googling, it tells me to delete the docker and compose it again. I used Portainer to stop and remove the container, but when trying to compose – the same old docker-image was started. Not sure why, maybe I have to use another command to delete the image? And the remove button just removes it from Portainer?

To upgrade I found a nice button in Portainer that said «Recreate». After clicking on this, I got a message asking to pull the latest image. This worked as a charm 🙂

 

Without Portainer

Pull latest image

 

Find docker ID.

Take the returned ID and remove container.