From Core to Docker

HI, I have been using Home Assistant Core for many years now and after facing upgrade hick-ups lately (late 2024), I plan to switch to a Docker configuration running Home Assistant container.
I have configured a Raspberry Pi 3B+ with Docker, and pulled Home Assistant from Docker Hub.
Now I want to transfer my config under Core to Docker Home Assistant container and it does not appear to be straight forward (in short, I copied the .homeassistant folder to the new device but the system does not start smoothly.
Am I doing something wrong? Is there somebody around who could guide me with the proper procedure to follow? Thank in advance

Can you share the command you used to start your container?
Also, if you are not using it yet, I would advise using docker compose instead of the command line. I find it a lot clearer and easier to replicate, and it also prevents me from having to remember the correct command every time I want to e.g. update.

It may also be useful to have the folder structure you got after copying.

I am somewhat assuming not starting smoothly means not starting at all btw. If that is not the case, can you elaborate on what exactly is not working?

1 Like

Also, whatever way you copied the .homeassistant folder to the folder mounted as /config in your docker container, be sure you included the hidden files/folders (e.g. .storage)

Hi! Thank you for your answer.
The script I used to start docker Home Assistant container is the following:

docker run --name homeassistant \
    --detach \
    --restart=always \
    --network=host \
    -v /home/homeassistant/.homeassistant/:/config \
    -v /home/pi/:/data \
    -e HA_URL="localhost:8123" \
    homeassistant/home-assistant

By the way, my old HA system is exposed on port 8130, and I would like to do the same with docker but I have not found the way to properly configure the -p option for doing so. Assistance would be appreciated.

The command I used is the following:

scp -r origin_device/.homeassistant destination_device:/home/homeassistant/.

and I effectively checked that all hidden files were there, and they were.

Not starting smoothly means that instead of having my Dashboard appearing as per the original device , I had the standard white and blue Home Assistant dashboard like if all the works I have done before was totally ignored (although the ui-lovelace file was transferred as well as the lovelace file inside .storage folder).

Ah, but all your data, dashboards etc. are present?
Because I believe the default dashboard is saved as a browser cookie, or at least not on your server directly. So when you spin up a new server on a different url, I would assume that cookie is not there. Same with themes.

Applying them again can be done quite quickly via the user tab.

If your dashboards are missing, can you check if you can find them in Settings ā†’ Dashboards? Maybe they have just been hidden from the sidebar.

Regarding your command, the one thing that I did notice, compared to the installation page (Advanced Raspberry Pi installations - Home Assistant), is the -e flag. In the example at least, it points to a timezone via TZ.

Changing the port can be done in your home assistant configuration, via

http:
  server_port: 8130

(see HTTP - Home Assistant)

1 Like

Thank you! I have not checked in details whether my dashboards was here indeed. I was stopped and shocked by the fact that I had to restart from scratch the process of adding integrations as I was only expecting to start like before with the screen I sent earlier.
I have dismounted the new system, waiting for better days to test again the use of docker with Home Assistant container.
As for the port, thank you. I was left with the impression that it had to be defined while launching the container(my bad).
Best.

Sorry for replying so late, I didnā€™t get a notification :sweat_smile:

So, the integrations you have set up were lost too? From what I remember from when I switched, that was not the case.

Let me know when you have time again to test :slight_smile: Speaking from experience, docker is a lot friendlier to use than core usually.

Hi, thank you for your message. I cannot confirm that the integrations that I had set-up were gone because, when I saw the new dashboard (standard colored white and blue) I told to myself that it was not good and that I had to redo everything, including the integration of my Zigbee components. I have more than 15 3-gangs switches (Zigbee), with most of them with a related automation.
However, I am still willing to move to docker because I agree with you that it is certainly simpler than Core version.
My first attempt, using another raspberry, was to make sure that I would not destroy my working system if something had to go wrong. Can you confirm that I would not face dramatic situation if I simply install docker on the existing Raspberry running Home Assistant, stop home-assistant.service (Core) and start Home Assistant container using the code below:

docker run --name homeassistant \
    --detach \
    --restart=always \
    --network=host \
    -v /home/homeassistant/.homeassistant/:/config \
    -e HA_URL="localhost:8130" \
    homeassistant/home-assistant

It is important that everything go well cos there are many users at home relying on the good performance of the system. Thank you in advance for your reply and advice.
Regards.

Why not the easy way?

  1. Backup
  2. Install new Home Assistant server
  3. Restore from backup

Done.

You donā€™t have a ā€œRestoreā€ in container installations (nor in Core).

Itā€™s not the way I want. I have been using Home Assistant Server (Core) for many years and I donā€™t want it any more. So your easy solution does not match my requirement.
For me the way for ward is Docker Home Assistant container.
Thanks anyway

I canā€™t answer to this question since I have not yet managed to proceed with docker up to the final situation where I am happy with the system I have.
In Home Assistant there is a possibility to do Restore from Backups but it appear that in the Core version of home assistant it is far from being strait forward.

So I wait for answer from people who would happen to know whether starting docker with home assistant on the same device which has been running Core is painless or not.
Thanks anyway.

It was not a question, but a fact :wink:

From what I can see, it looks good. One precaution I would take in your case, is making sure you donā€™t point the container to the same folder as you were running core in. That should not be the case if you set up the backup and everything, but just in case. (although I would still advice keeping the backup somewhere safe).

Your command still needs to be updated with the correct info (i.e. TZ_INFO). It also seems the last line, that should point the container image, is incorrect? At least, in the documentation, it is ghcr.io/home-assistant/home-assistant:stable.

From what I can see, it should not lead to any dramatic situations (and wrong commands should also be caught out by docker).

Hi, attempted a fresh start with docker yesterday after having backed-up my config folder. Amended the startup script as you recommended.
Docker permanently restarts after a few seconds. I give up and will try something else another day, another time. Thanks

docker run -d \
  --name ha \
  --privileged \
  --restart=unless-stopped \
  -e TZ=America/Los_Angeles \
  -v /home/homeassistant/.homeassistant:/config \
  -v /run/dbus:/run/dbus:ro \
  --network=host \
  ghcr.io/home-assistant/home-assistant:stable

I stumbled upon this topic when I was also looking for documentation on migrating from core to docker. Went pretty smoothly, so Iā€™ll leave the details here for anyone to find. Please note: my docker container is set via ansbile, so you may need to translate to the appropriate docker arguments, though they should be pretty much the same.

  1. Make sure that the version on the docker container is the same as your current setup! You can upgrade later if so desired.
  2. Create and start container:

- name: Create the home assistant container
  tags: home-assistant
  become: true
  community.docker.docker_container:
    name: home-assistant
    image: ghcr.io/home-assistant/home-assistant:2024.12.2
    restart_policy: unless-stopped
    env:
      TZ: Europe/Amsterdam
    ports:
      - "8123:8123"
    volumes:
      - /srv/docker/home-assistant:/config
  1. Stop the container and stop the current service (docker stop home-assistant, systemctl stop home-assistant`). Make sure the current service is stopped by visiting the URL where your instance was running.
  2. Important!: figure out the owner of the data of the container with ls -nd:
drwxrwxrwx 11 1001 1002 4096 Mar  2 19:59 home-assistant/

note down the 1001:1002, youā€™ll need it later.
4. Remove the current config. In my example: rm -r /srv/docker/home-assistant.
5. Copy over the existing config, in my case: cp -ap /srv/homeassistant/config /srv/docker/home-assistant.
6. Make sure ls /srv/docker/home-assistant looks like this:

automations.yaml
blueprints
configuration.yaml
custom_components
deps
home-assistant.log
home-assistant.log.1
home-assistant_v2.db
scenes.yaml
scripts.yaml
secrets.yaml
tts 
  1. Change the owner to what the container expected and what we gathered in step 3, in my example 1001:1002, by running chown 1001:1002 -R /srv/docker/home-assistant.
  2. Restart the docker container: docker start home-assistant and everything should be working!

Thank you very much! Iā€™ll give it a try and revert when job is done.
Best

After a few days, I have tried to implement what was described by @Nebula83 but I did not succeed so I decided to take another approach:
My Home Assistant Core runs on a Raspberry Pi with Dietpi OS.
Dietpi OS comes with a wide range of Software which can be installed automatically (probably ansible scripts developed by Dietpi Team - very handy). This is how I originally had installed Home Assistant, so I decided to git a try to a full re-installation (after having taken a backup of my ā€˜configā€™ file).

Guess what? Re-installation is not destructive. It took quite some time as everything is re-installed but itā€™s worth it! Everything works as expected.

I do confirm that Dietpi OS is very good operating system running on Raspberry Pi. https://dietpi.com