Part 1 - How to update Home Assistant Docker in Debian via docker run- mounts Type-Bind
How to upgrade Home Assistant Container Properly?
Table of Contents
OS:Debian GNU/Linux 12 (bookworm)
@raspberrypi:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm
Pull the latest stable Home Assistant image with the command below:
docker pull ghcr.io/home-assistant/home-assistant:stable
Recreate a new container with the same docker run parameters
Stop the existing Home Assistant Container.
docker stop homeassistant
Remove the existing Home Assistant Container
docker rm homeassistant
Execute the Docker run command the same way as you did during the initial installation of Home Assistant Container
docker run -d \
--name homeassistant \
--privileged \
--restart=unless-stopped \
-e TZ=MY_TIME_ZONE \
-v /PATH_TO_YOUR_CONFIG:/config \
--network=host \
ghcr.io/home-assistant/home-assistant:stable
If everything is fine with the above commands, you should have an updated to the latest stable release Home Assistant Container installation.
Step by step
Home assistant install type
Via Docker Run
Docker store persistent data type
Bind mounts
Quick Start
You have to map the container folder and copy config folder including all hidden folders to new HA to transfer all data.
Install
docker pull ghcr.io/home-assistant/home-assistant:stable
Before you run home assistant in docker you need to first decide where you will store persistent data.
Docker has two options:
Volumes
Bind mounts
source:https://stevessmarthomeguide.com/running-home-assistant-in-a-docker-container/
The docker install instructions use bind mounts and that is what I will use here.
Update
Get the current name of your container and version
sudo docker ps
Validate your current version
docker inspect -f '{{ index .Config.Labels "org.opencontainers.image.version" }}' ha
Output
2024.1.5
detail:http://localhost:4999/boards/topic/15671/docker-cli/page/2#28522
Create a backup
To update it, first Backing up Configuration
sudo cp /home/docker/home-assistant/ /home/docker/home-assistant-backup/ -R
note: some data is in an invisible folder called .storage.
backup your config by copying all the files in the mount point to your volume.
Stop and delete the container
Replace the name of the container in the command below with the value you had.
#it COMPLETELY REMOVED ALL OF Your CONFIGURATION and you had to re-add all of your devices, integrations, automations.... everything...
sudo docker stop home-assistant #stop the running container
sudo docker rm home-assistant #delete the container,COMPLETELY REMOVED ALL OF Your CONFIGURATION
Note
this will COMPLETELY REMOVED ALL OF MY CONFIGURATION and I had to re-add all of my devices, integrations, automations.... everything...
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 ghcr.io
Replace the value below with your IMAGE value you documented in the previous steps.
docker pull ghcr.io/home-assistant/home-assistant:stable
Validate your Image version version
docker inspect -f '{{ index .Config.Labels "org.opencontainers.image.version" }}' ghcr.io/home-assistant/home-assistant:stable
Output
2024.2.1
Deploy the container
Recreate a new container with the same docker run parameters
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 homeassistant/raspberrypi4-homeassistant:stable
Validate your current version
before
~# docker inspect ha
output
[
{
"Id": "326e0b2280982697cc0fc6eca9e58b0b34ac462447cbd2d7e01f142a54f9001b",
"Created": "2024-01-26T22:25:08.810342657Z",
"Path": "/init",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 41059,
"ExitCode": 0,
"Error": "",
"StartedAt": "2024-02-23T21:49:16.109782932Z",
"FinishedAt": "2024-02-23T21:49:14.539687603Z"
},
"Image": "sha256:9c19b1fddc11c5ef1ed7964e62c7e8d68613c5cfc3aeef11d110eec6848447c1",
"ResolvConfPath": "/var/lib/docker/containers/326e0b2280982697cc0fc6eca9e58b0b34ac462447cbd2d7e01f142a54f9001b/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/326e0b2280982697cc0fc6eca9e58b0b34ac462447cbd2d7e01f142a54f9001b/hostname",
"HostsPath": "/var/lib/docker/containers/326e0b2280982697cc0fc6eca9e58b0b34ac462447cbd2d7e01f142a54f9001b/hosts",
"LogPath": "/var/lib/docker/containers/326e0b2280982697cc0fc6eca9e58b0b34ac462447cbd2d7e01f142a54f9001b/326e0b2280982697cc0fc6eca9e58b0b34ac462447cbd2d7e01f142a54f9001b-json.log",
"Name": "/ha",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/home/homeassistant20221103:/config"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "host",
"PortBindings": {},
"RestartPolicy": {
"Name": "always",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"ConsoleSize": [
35,
107
],
"CapAdd": null,
"CapDrop": null,
"CgroupnsMode": "private",
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "private",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": [],
"BlkioDeviceWriteBps": [],
"BlkioDeviceReadIOps": [],
"BlkioDeviceWriteIOps": [],
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": null,
"PidsLimit": null,
"Ulimits": [],
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware",
"/sys/devices/virtual/powercap"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/1d6ab8d732e6caa0403539b939a631c5b9d591dd32020c5ea6065674b4318c3a-init/diff:/var/lib/docker/overlay2/861b7eb03f755e9fdf2c23fec759a60e1c895d19f6f72e17697ff2c2166ed397/diff:/var/lib/docker/overlay2/03c548226bab66549f5d1813f92b151503ff695d7bcf4c42b845e86b4edd7759/diff:/var/lib/docker/overlay2/eba670937a7f85d6ebe7267d4b5fb8bff3c183b6780d4530eaa7a73c8125036e/diff:/var/lib/docker/overlay2/44540c46fff2c210928aed51cc5aba2ca15b98fc79c029b8aa51e9c37d573267/diff:/var/lib/docker/overlay2/4eb988211c3a06625ebc567f01ea9039643b4a7ca672cf6997fd7dea17ec7e7f/diff:/var/lib/docker/overlay2/625e07f2fd482e92d33b0bf0b393166b9175a98f64f4be2e24dcc88fb27ba11c/diff:/var/lib/docker/overlay2/dc736f1471a796127c2d722ece89d6f044fb801c8c311fe0db14eb48335429cd/diff:/var/lib/docker/overlay2/6a0b586defa36ecc063db0341a3d4a80e75d9dbdbf64b7ae5b3f318e64757bf1/diff:/var/lib/docker/overlay2/37be7c0aed96c15e38b773e5ca4663e7303576caf09d67f575d2c56b9061620e/diff:/var/lib/docker/overlay2/40a07b14aa34965c192234c5c49b475ea662f0b1dc9d944d651c55b850932d65/diff:/var/lib/docker/overlay2/049c53f7c74dde3f80adc7f87fdc279c680bdc3f01946d9c5973e73729738b5b/diff:/var/lib/docker/overlay2/b49c48279f535d6ef6b748ba5b97b1e0dce8165a95c6a91832c9de0c052194c8/diff:/var/lib/docker/overlay2/69853d7d0580259e7a9b8a4753c63d8a104f8f8cda9967e1db390f4c95a69242/diff:/var/lib/docker/overlay2/fcabbe11d89573d2d8b396aa0a59c101fff017634a232039b4272f522595b477/diff:/var/lib/docker/overlay2/e3b05f50bf3039aa8b85ff6e9519c6bbb2ff3959400387f98ff0196e250b74af/diff:/var/lib/docker/overlay2/959a82693bc88bb2b40f634011ee40f3aba24faeb3374e79426955ce63a821bd/diff:/var/lib/docker/overlay2/3e82ccc6dad797d9d9e80ae7cf87424eb38945f352f387490530cc97463ffa4d/diff:/var/lib/docker/overlay2/6466d1d1d8395973bc4f6a36590bffd4e0ffd099f87804274e12aab75deb30ba/diff:/var/lib/docker/overlay2/9e18bf495f1b02a7dea542c55cb05dfc5618f6f650dc2a4a9012894e89d0f4a4/diff:/var/lib/docker/overlay2/6ae6ff64d8bbed3373322d0aed1df7d4942a064762993c1d48f10d1ca9120287/diff:/var/lib/docker/overlay2/f0dd11547de906a26e218437decc0f7e34b989b38e9ce4bac3f16f80dc4b7e3f/diff:/var/lib/docker/overlay2/7ab07e5a964a24f81099335eec5af321ffab3a2c0bbf1ef3b486e83f49802d47/diff:/var/lib/docker/overlay2/11eae3b21016be373c6ac0fe2f66e9f436aa927e85790fbcf97f4af9a4ddba48/diff:/var/lib/docker/overlay2/45f10b6e7b435c5b8aec75ec44e839d3c481fa28fcc79c6bb30f47db75080e8c/diff:/var/lib/docker/overlay2/16da3a94dfe25323978885e48b269303cc7bd8b64e7253b98956a9e02970e22e/diff:/var/lib/docker/overlay2/0c9a2e75c974326846810fd5a41f604f6f19f6856486a5dad0982d26061b6788/diff:/var/lib/docker/overlay2/6710901affc1ffcef0b46c640abe9e178e8892fcdc7373f4f568287794090db2/diff:/var/lib/docker/overlay2/34a8427b4bd560358be935f84a1fd7e486608aa2d74bf9e9e4130e5b4fa22bdc/diff:/var/lib/docker/overlay2/36a7a413154a5b44a7897e20eb56eed1967412752928862c995179edb71164c8/diff:/var/lib/docker/overlay2/e46818bdc762e6e97566ac6add6481630ccb4a7ffdcd1cdca6e39223bc23850e/diff",
"MergedDir": "/var/lib/docker/overlay2/1d6ab8d732e6caa0403539b939a631c5b9d591dd32020c5ea6065674b4318c3a/merged",
"UpperDir": "/var/lib/docker/overlay2/1d6ab8d732e6caa0403539b939a631c5b9d591dd32020c5ea6065674b4318c3a/diff",
"WorkDir": "/var/lib/docker/overlay2/1d6ab8d732e6caa0403539b939a631c5b9d591dd32020c5ea6065674b4318c3a/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "bind",
"Source": "/home/homeassistant20221103",
"Destination": "/config",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
}
],
"Config": {
"Hostname": "raspberrypi",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"LANG=C.UTF-8",
"S6_BEHAVIOUR_IF_STAGE2_FAILS=2",
"S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0",
"S6_CMD_WAIT_FOR_SERVICES=1",
"S6_SERVICES_READYTIME=50",
"S6_SERVICES_GRACETIME=240000"
],
"Cmd": null,
"Image": "ghcr.io/home-assistant/home-assistant:stable",
"Volumes": null,
"WorkingDir": "/config",
"Entrypoint": [
"/init"
],
"OnBuild": null,
"Labels": {
"io.hass.arch": "aarch64",
"io.hass.base.arch": "aarch64",
"io.hass.base.image": "ghcr.io/home-assistant/aarch64-base:3.18",
"io.hass.base.name": "python",
"io.hass.base.version": "2023.10.4",
"io.hass.type": "core",
"io.hass.version": "2024.1.5",
"org.opencontainers.image.authors": "The Home Assistant Authors",
"org.opencontainers.image.created": "2024-01-20 19:03:46+00:00",
"org.opencontainers.image.description": "Open-source home automation platform running on Python 3",
"org.opencontainers.image.documentation": "https://www.home-assistant.io/docs/",
"org.opencontainers.image.licenses": "Apache License 2.0",
"org.opencontainers.image.source": "https://github.com/home-assistant/core",
"org.opencontainers.image.title": "Home Assistant",
"org.opencontainers.image.url": "https://www.home-assistant.io/",
"org.opencontainers.image.version": "2024.1.5"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "5ec42f22a96e23d7a4a8133c97aead431cd3769f5ece0b3a8db38f6f6d7ae383",
"SandboxKey": "/var/run/docker/netns/default",
"Ports": {},
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"host": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"MacAddress": "",
"NetworkID": "28840cda2978aad0c9b518e82f42d2a45eed681adb25372ec7d79795b6313351",
"EndpointID": "e6bd0b78ef5730f6756f7a2eb3a1879fb1c85446db5836c9a2bbbb094e53e49c",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"DriverOpts": null,
"DNSNames": null
}
}
}
}
]
http://localhost:4999/boards/topic/20883/how-to-install-uninstall-and-reinstall-update-home-assistant-docker-in-debian#28434
Useful links
https://jackstromberg.com/2020/03/how-to-update-home-assistant-docker-container
http://localhost:4999/boards/topic/20894/home-assistant-docker-upgrade-backup-old-home-assistant-docker-and-install-new-home-assistant-docker
http://localhost:4999/boards/topic/20883/how-to-install-uninstall-and-reinstall-update-home-assistant-docker-in-debian#28435
Comments
Comments are closed