How to update Home Assistant Docker Container

Continuing from my previous guide on how to setup Home Assistant + Docker + Z-Wave + Raspberry Pi, this tutorial will show you how to update Home Assistant to the latest version. Updating Home Assistant to the latest version is critical to ensure you have the latest bug fixes, integrations, and security patches.

Note: during the update your devices will continue to work fine, but please note any automations or access to the application will not be available, so it's recommended to do this during a time that you know no automations will be running.

Validate your current version

Navigate to the Developer Tools section of Home Assistant. Here you can validate the latest version you currently have deployed.

Get the current name of your container and version

sudo docker ps

In running this command, note the NAME of your container as well as the IMAGE.

Stop and delete the container

Replace the name of the container in the command below with the value you had.

sudo docker stop home-assistant
sudo docker rm home-assistant

Update packages

Some versions of HA require newer versions of Python, Docker, etc. I may consider updating to latest package versions first.

sudo apt-get update
sudo apt-get upgrade

Pull the latest container from Docker Hub

Replace the value below with your IMAGE value you documented in the previous steps.

sudo docker pull ghcr.io/home-assistant/raspberrypi4-homeassi                                                                                                             stant:stable

Deploy the container

Make sure your replace the name and value of the image with the values in the previous step. In addition, ensure you specify the correct path to where you existing configuration files exist to have the container load your existing configurations.

sudo docker run -d --restart=always --name="home-assistant" -e "TZ=America/Chicago" --device=/dev/ttyACM0 -v /home/docker/home-assistant:/config --net=host ghcr.io/home-assistant/raspberrypi4-homeassistant:stable

Note: If you are now using the Z-Wave JS docker container, you will not want to attach the Z-Wave stick to the Home-Assistant container. In this case, run the following command:

sudo docker run -d --restart=always --name="home-assistant" -e "TZ=America/Chicago" -v /home/docker/home-assistant:/config --net=host ghcr.io/home-assistant/raspberrypi4-homeassistant:stable

Validate your version number

After a few minutes, navigate back to the Developers Tools page. Upon load, you should now be on the latest version of Home Assistant.

Notes:

You can find the latest, stable, and development builds out on docker hub here: https://hub.docker.com/u/homeassistant

For example, for raspberrypi4 builds, here you can validate the versions of all the different containers offered: https://hub.docker.com/r/homeassistant/raspberrypi4-homeassistant/tags

In newer versions of the docker container --init should not be specified in the docker run command. Specifying --init will result with the following error: "s6-overlay-suexec: fatal: can only run as pid 1". This was mentioned as a breaking change in: 2022-06-01 update: 2022.6: Gaining new insights! - Home Assistant (home-assistant.io)

11 thoughts on “How to update Home Assistant Docker Container

  1. Some Annoyed Guy

    While this successfully updated my Home Assistant, it COMPLETELY REMOVED ALL OF MY CONFIGURATION and I had to re-add all of my devices, integrations, automations.... everything...

    Perhaps the author should have mentioned something about this

    Reply
    1. Jack Post author

      If the update wiped your devices/configuration, it sounds like the path of where your configuration is stored is different from what is listed in the article. On the Deploy the container step, this is called out.

      Reply
      1. Luis

        Hey,

        this is not right 😅
        This method also removed all of my config even though I changed the path to the correct one..
        I don't know why this differs to your installation but the only thing I noticed was different was that your version-numbers are in a 0.xxx.xx format, while mine are in a 2021.x.x (basically a date) format.

        For me it's not too bad since I was just starting to set it up but I can see why someone following this guide might be very upset.

        Greetings
        Luis

        Reply
        1. Jack Post author

          The guide was written prior to the 20XX.X.X version nomenclature, but still holds true to the latest versions using the 20XX.X.X versions. I still use this guide for updating my version of Home Assistant and the settings do persist. Make sure you are pointing to the proper directory you used to store your configuration; the commands themselves assumes the configuration for your HA deployment is in /home/docker/home-assistant; yours may be different.

          I've gone ahead and updated the images to show this is possible as well.

          Hope this helps!
          Jack

          Reply
        2. Oscar

          All this guide does is to replace the docker container with a later version of it. If you run the new container with docker run the same way as you ran your container before, the configuration will persist as it is outside the docker container.

          Reply
  2. Pingback: How to upgrade Home Assistant Z-Wave integration to Z-Wave JS for Docker | Jack Stromberg

  3. Pingback: How to update Z-Wave JS Docker Container | Jack Stromberg

  4. tom

    "Note: If you are now using the Z-Wave JS docker container, you will not want to attach the Z-Wave stick to the Home-Assistant container. In this case, run the following command:"

    Is this sentence correct? or did you mean, 'if you are NOT using the Z-Wave JS docker container'?

    Reply
    1. Jack Post author

      The sentence is correct. You'd want the device to have access to the Z-Wave JS docker container, not the Home Assistant container.

      Hope this helps!
      Jack

      Reply
  5. Mike

    Is still the best way to update the docker? My home assistant is saying my setup is unhealthy...

    I don't want to loose my configuration, can I take a backup just in case? Which file contains all devices and settings?

    My current Core version is core-2021.8.6 , supervisor is up to date (2023.03.1), Home Assistant OS 5.13...

    Reply
    1. Jack Post author

      I still use these steps today. You can backup your config by copying all the files in the mount point to your volume.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *