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.
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:
version: '3' services: homeassistant: container_name: home-assistant image: homeassistant/home-assistant volumes: - /home/homeassistant/.homeassistant:/config - /etc/localtime:/etc/localtime:ro devices: - /dev/ttyACM0:/dev/ttyACM0 restart: always network_mode: host
You need to change the config-path under volumes to your own, and map any devices you might have.
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 -s`-`uname -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:
user@homeassistant:/home/homeassistant/.homeassistant# docker-compose up Recreating home-assistant ... done Attaching to home-assistant home-assistant | 2018-03-11 23:13:39 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=homeassistant, service=turn_off> home-assistant | 2018-03-11 23:13:39 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=homeassistant, service=turn_on> home-assistant | 2018-03-11 23:13:39 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=homeassistant, service=toggle> home-assistant | 2018-03-11 23:13:39 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=homeassistant, service=stop> home-assistant | 2018-03-11 23:13:39 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=homeassistant, service=restart> ...
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 🙂
Pull latest image
# docker pull homeassistant/home-assistant:0.66.1 0.66.1: Pulling from homeassistant/home-assistant f2b6b4884fc8: Already exists 4fb899b4df21: Already exists 74eaa8be7221: Already exists 2d6e98fe4040: Already exists 414666f7554d: Already exists 7e765f6e07f8: Already exists 6f02823cd02e: Already exists 9239d3c3d426: Already exists c4588092e44e: Pull complete 0df739409539: Pull complete ec55ff9b9eba: Downloading [========> ] 24.54 MB/138.8 MB 4612542e1cd0: Download complete d0adb9eb47e0: Downloading [====> ] 12.37 MB/140.1 MB
Find docker ID.
# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 62cc40bf3fed homeassistant/home-assistant "python -m homeass..." 2 minutes ago Exited (137) About a minute ago
Take the returned ID and remove container.
# docker rm <id>
# docker-compose up -d Creating home-assistant ... done