Docker install upgrade failed to retrieve config

Hello,

My homeassistant install has been running fine for 5 months using Docker :heart_eyes:

CONTAINER ID   IMAGE                                          COMMAND                  CREATED        STATUS                  PORTS                                                                                            NAMES
c963af3485e8   ghcr.io/home-assistant/home-assistant:stable   "/init"                  5 months ago   Up 4 months                                                                                                              homeassistant

Today, I wanted to update this and I placed the following commands :open_mouth:

$ docker stop homeassistant
$ docker rm home-assistant
$ docker run -d \
  --name homeassistant \
  --privileged \
  --restart=unless-stopped \
  -e TZ=Europe/Paris \
  -v ./hass-config:/config \
  --network=host \
  ghcr.io/home-assistant/home-assistant:stable

I can still log into 192.168.0.120:8123 but this redirects me to /onboarding.html
so I guess I lost all my configuration? :sob:

$ docker ps

gets me

CONTAINER ID   IMAGE                                          COMMAND                  CREATED          STATUS                  PORTS                                                                                            NAMES
99b6a965ec9d   ghcr.io/home-assistant/home-assistant:stable   "/init"                  53 seconds ago   Up 52 seconds                                                                                                            homeassistant

Fortunately I saved a local .tar backup

Is there a way to get my config back? or force/reload my config?

Thanks in advance,

It sounds like the Docker container can’t find or read ./hass-config which is on the Docker host. Is that really the right path? That means Docker is looking for a folder called haas-config in the same directory as the Docker executable (I think anyway). If that’s the exact command you normally use, then you need to see why Docker can’t see that directory. If you’ve accidentally done a different volume mapping, you need to fix it and do docker run again.

Wow, thanks for the fact answer!

I think you’re touching the truth :blush:

Here is how I verified that hass-config folder exists

$ ls /home/[USER]/hass-config/
automations.yaml          configuration.yaml        home-assistant.log        home-assistant_v2.db      scenes.yaml               .storage/                 
blueprints/               deps/                     home-assistant.log.1      home-assistant_v2.db-shm  scripts.yaml              tts/                      
.cloud/                   .HA_VERSION               home-assistant.log.fault  home-assistant_v2.db-wal  secrets.yaml

I am ok running command lines,
somehow ok using linux
but I’m definitely new to Docker, Portainer and HomeAssistant.

How can I verify that

a folder called haas-config [is present] in the same directory as the Docker executable

?

It looks like you need to be in /home/[USER]/ when you executed docker run -d. Were you?

if not, try this:

$ docker run -d \
  --name homeassistant \
  --privileged \
  --restart=unless-stopped \
  -e TZ=Europe/Paris \
  -v `/home/[USER]/hass-config:/config \
  --network=host \
  ghcr.io/home-assistant/home-assistant:stable

Note: I have replaced ./ (relative path) with /home/[USER]/ (absolute path). I’m guessing you will still need to replace [USER] with our actual user name.

I was not. Thanks. This helps me to better understand Docker.

I tried

$ docker run -d \
  --name homeassistant \
  --privileged \
  --restart=unless-stopped \
  -e TZ=Europe/Paris \
  -v `/home/[USER]/hass-config:/config \
  --network=host \
  ghcr.io/home-assistant/home-assistant:stable

replacing [USER] at the default (root) level "~$ "
For an unknown reason, this feeds me back a single “>” at the line below like it would expect some parameter before executing…
[I am still able to get out using ctrl + c]

EDIT
removing the single quote

-v `/home/[USER]/hass-config:/config
-v /home/[USER]/hass-config:/config

was the solution for this to execute.

Next problem: I am still getting the “Welcome” screen with “Create my smart home” button.
I am reluctant to click because I get a feeling this could overwrite my existing config…
Or simply my config was still not taken into account…?

How can I verify this to be 100% sure?
I tried:

$ docker inspect homeassistant | grep "/config"
                "/home/[USER]/hass-config:/config"
                "Destination": "/config",
            "WorkingDir": "/config",

→ I would expect to see my existing home and its config instead of the Welcome screen…

As a side note:

$ ls -l /home/[USER]/hass-config/
total 848
-rw-r--r-- 1 root root      2 Apr 13 22:24 automations.yaml
drwxr-xr-x 4 root root   4096 Apr 13 22:24 blueprints
-rw-r--r-- 1 root root    265 Apr 13 22:24 configuration.yaml
drwxr-xr-x 2 root root   4096 Apr 13 22:24 deps
-rw-r--r-- 1 root root    343 Apr 14 22:17 home-assistant.log
-rw-r--r-- 1 root root  63257 Apr 14 16:20 home-assistant.log.1
-rw-r--r-- 1 root root      0 Apr 14 22:17 home-assistant.log.fault
-rw-r--r-- 1 root root 368640 Apr 14 22:06 home-assistant_v2.db
-rw-r--r-- 1 root root  32768 Apr 14 22:20 home-assistant_v2.db-shm
-rw-r--r-- 1 root root 366712 Apr 14 22:20 home-assistant_v2.db-wal
-rw-r--r-- 1 root root      0 Apr 13 22:24 scenes.yaml
-rw-r--r-- 1 root root      0 Apr 13 22:24 scripts.yaml
-rw-r--r-- 1 root root    161 Apr 13 22:24 secrets.yaml
drwxr-xr-x 2 root root   4096 Apr 13 22:24 tts

EDIT2:
When writing this, I noticed that the dates were all too recent to be true.

So I came back to the the original tutorial which helped me with the install:

And I noticed that the path to config files was different.

I then did:

$ docker stop homeassistant
$ docker rm home-assistant
$ docker run -d --name homeassistant --privileged --restart=unless-stopped -e TZ=Europe/Paris -v /opt/homeassistant/config:/config --network=host ghcr.io/home-assistant/home-assistant:stable

And miracle! It works again :muscle:

Now next step is to understand why it’s still in 2023.11.2 whereas my initial goal was to update it…

1 Like

OK, I wrote a post and then saw that you actually found the original config directory - fantastic.

As a side note, I recommend you use a docker compose file which holds* all the* information for you so you don’t forget it.

This is what your compose.yaml would look like:

name: "smarthome" # or any name you like
services:
  homeassistant:
    container_name: homeassistant
    image: ghcr.io/home-assistant/home-assistant:stable
    volumes:
      - /opt/homeassistant/config:/config
      #- /etc/localtime:/etc/localtime:ro
      #- /run/dbus:/run/dbus:ro
    environment:
      - TZ=Europe/Paris
    network_mode: host
    privileged: true
    restart: unless-stopped

You can put your compose.yaml file anywhere as you are using an absolute path for /opt/homeassistant/config.

Make sure you cd into the directory where your compose.yaml file is located (perhaps /home/[USER]/) and then do the following:
docker compose pull
docker compose up -d
…and then check homeassistant.
…and backup first :+1:

[typo*]

Thanks again jchh ( Shall I call you John? :innocent: )

So I found that I had a compose.yaml file:

$ docker-compose -f /opt/docker-compose.yaml config
containerd/          duplicati/           esphome/             homeassistant/       mariadb/             nodered/             zigbee2mqtt/         
docker-compose.yaml  .env                 hassconf/            influxdb/            mosquitto/           portainer/    

Here is an extract of the hass part of the compose.yaml file

homeassistant:
    container_name: homeassistant
    depends_on:
      influxdb:
        condition: service_started
        required: true
      mariadb:
        condition: service_started
        required: true
    environment:
      TZ: Europe/Paris
    image: ghcr.io/home-assistant/home-assistant:stable
    network_mode: host
    privileged: true
    restart: unless-stopped
    volumes:
    - type: bind
      source: /opt/homeassistant/config
      target: /config
      bind:
        create_host_path: true
    - type: bind
      source: /etc/localtime
      target: /etc/localtime
      read_only: true
      bind:
        create_host_path: true

Then I did

$ cd /opt
/opt$ docker compose pull
[+] Pulling 78/43
 ✔ portainer 11 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled                                                                                                                   16.2s 
 ✔ hass-configurator Pulled                                                                                                                                                    1.2s 
 ✔ mosquitto 3 layers [⣿⣿⣿]      0B/0B      Pulled                                                                                                                            12.5s 
 ✔ mariadb 8 layers [⣿⣿⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled                                                                                                                         40.4s 
 ✔ nodered 16 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled                                                                                                                55.5s 
 ✔ esphome 9 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled                                                                                                                        57.7s 
 ✔ influxdb 10 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled                                                                                                                     36.0s 
 ✔ homeassistant Pulled                                                                                                                                                        0.7s 
 ✔ watchtower Pulled                                                                                                                                                           1.2s 
 ✔ zigbee2mqtt 10 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled                                                                                                                  20.5s 
 ✔ duplicati Pulled                                                                                                                                                            1.2s




/opt$ docker compose up -d
[+] Running 7/9
 ✔ Container duplicati                                                Running                                                                                                  0.0s 
 ✔ Container mosquitto                                                Recreated                                                                                                1.7s 
 ⠼ Container zigbee2mqtt                                              Recreate                                                                                                 2.4s 
 ✔ Container opt-watchtower-1                                         Created                                                                                                  0.0s 
 ⠼ Container esphome                                                  Recreate                                                                                                 2.4s 
 ✔ Container influxdb                                                 Recreated                                                                                                1.9s 
 ✔ Container mariadb                                                  Recreated                                                                                                2.4s 
 ✔ Container portainer                                                Recreated                                                                                                2.0s 
 ! esphome Published ports are discarded when using host network mode                                                                                                          0.0s 
 ⠋ Container homeassistant                                            Creating                                                                                                 0.0s 
Error response from daemon: Conflict. The container name "/homeassistant" is already in use by container "9baaa3824dea054a377f101044ca77ff66bc418eb033cabf68516e0c5ce16f73". You have to remove (or rename) that container to be able to reuse that name.

I am not sure to understand where the issue is. Is that linked to me removing (rm) homeassistant befire reinstalling (docker run -d) or is that bound to “docker compose up -d” trying to create a temporary container during the update?
Any idea how to solve this?

I think you were trying to run 2 instances of Homeassistant. Did you stop the one you ran earlier first?

I know you are kidding but you would not believe how many people mistake my initials for the name “John” :crazy_face:

I believe I have a single one running, but better double checking:

/opt$ docker ps -a
CONTAINER ID   IMAGE                                 COMMAND                  CREATED          STATUS                        PORTS                                       NAMES
286a5fe7dc3d   portainer/portainer-ce:latest         "/portainer"             12 minutes ago   Created                                                                   portainer
4eb68e97e7ca   influxdb                              "/entrypoint.sh infl…"   12 minutes ago   Created                                                                   influxdb
123b1bfd4698   mariadb                               "docker-entrypoint.s…"   12 minutes ago   Created                                                                   mariadb
ac484de9fbe5   esphome/esphome                       "/entrypoint.sh dash…"   12 minutes ago   Created                                                                   aeeb872ee0fb_esphome
6f905641ee50   koenkk/zigbee2mqtt                    "docker-entrypoint.s…"   12 minutes ago   Created                                                                   e312320f8a5a_zigbee2mqtt
dccf398f6abe   eclipse-mosquitto                     "/docker-entrypoint.…"   12 minutes ago   Created                                                                   mosquitto
9baaa3824dea   3f32ac3a3d6f                          "/init"                  34 minutes ago   Up 34 minutes                                                             homeassistant
fa057da3c9a7   ckware/ti-cc-tool                     "run -ewv -p /dev/tt…"   5 months ago     Exited (1) 5 months ago                                                   competent_bartik
300cae0e5f69   ckware/ti-cc-tool                     "run -ewv -p /dev/tt…"   5 months ago     Exited (1) 5 months ago                                                   dazzling_napier
998c1cab6b9d   ckware/ti-cc-tool                     "run -ewv -p /dev/tt…"   5 months ago     Created                                                                   thirsty_kepler
46bf27043018   ckware/ti-cc-tool                     "run -ewv -p /dev/tt…"   5 months ago     Created                                                                   zealous_rhodes
40534da9947a   ckware/ti-cc-tool                     "run -ewv -p /dev/tt…"   5 months ago     Exited (1) 5 months ago                                                   cranky_joliot
17b9071c893a   ckware/ti-cc-tool                     "run -ewv -p /dev/tt…"   5 months ago     Exited (1) 5 months ago                                                   sleepy_bartik
26973f055479   ckware/ti-cc-tool                     "run -ewv -p /dev/tt…"   5 months ago     Exited (1) 5 months ago                                                   funny_perlman
686a7417fec1   ckware/ti-cc-tool                     "run -ewv -p /dev/tt…"   5 months ago     Exited (1) 5 months ago                                                   nifty_boyd
130a2e0b83e6   ckware/ti-cc-tool                     "run -ewv -p /dev/tt…"   5 months ago     Exited (1) 5 months ago                                                   infallible_fermi
649f192ddbb5   bc24c33b020b                          "./entrypoint.sh"        5 months ago     Up 4 months (healthy)         0.0.0.0:1880->1880/tcp, :::1880->1880/tcp   nodered
aeeb872ee0fb   7e6339ba5f8e                          "/entrypoint.sh dash…"   5 months ago     Exited (137) 12 minutes ago                                               esphome
0e963ffb74d9   duplicati/duplicati                   "/usr/sbin/tini -- /…"   5 months ago     Up 4 months                   0.0.0.0:8200->8200/tcp, :::8200->8200/tcp   duplicati
c4a372e5dc6c   containrrr/watchtower                 "/watchtower"            5 months ago     Exited (255) 5 months ago     8080/tcp                                    opt-watchtower-1
d3db67481128   causticlab/hass-configurator-docker   "/app/run.sh"            5 months ago     Up 4 months                   0.0.0.0:3218->3218/tcp, :::3218->3218/tcp   hassconf

IMO, there is a single one running. What do you think?

let’s clear that up.

run the follwojg to remove all unused volumes, containers etc etc.
docker system prune --volumes -f

Then try docker compose up -d again.

Hello,

I ran

/opt$ docker system prune --volumes -f

Lots of deleted containers and images :ok_hand:

Then:

/opt$ docker compose up -d
[+] Running 9/8
 ✔ Container zigbee2mqtt                                              Created                                                                                                  0.2s 
 ✔ Container opt-watchtower-1                                         Created                                                                                                  0.2s 
 ✔ Container esphome                                                  Created                                                                                                  0.2s 
 ✔ Container portainer                                                Created                                                                                                  0.2s 
 ✔ Container mariadb                                                  Created                                                                                                  0.2s 
 ✔ Container mosquitto                                                Created                                                                                                  0.2s 
 ✔ Container influxdb                                                 Created                                                                                                  0.2s 
 ✔ Container duplicati                                                Running                                                                                                  0.0s 
 ! esphome Published ports are discarded when using host network mode                                                                                                          0.0s 
 ⠋ Container homeassistant                                            Creating                                                                                                 0.0s 
Error response from daemon: Conflict. The container name "/homeassistant" is already in use by container "9baaa3824dea054a377f101044ca77ff66bc418eb033cabf68516e0c5ce16f73". You have to remove (or rename) that container to be able to reuse that name.

Is it possible that this relates to me having installes homassistant in command line while it was already existing in my compose.yaml ?

How to sort it out? Any direction would be much appreciated :sweat_smile:

Hi,

I think you’re getting there, but you clearly have 2 homeassistant containers.

Let’s try to stop and remove the ‘other’ running container:

Stop:
9baaa3824dea054a377f101044ca77ff66bc418eb033cabf68516e0c5ce16f73

Prune (again):
docker system prune --volumes -f

Restart:
docker compose up -d

Thanks a million :partying_face:

I discovered that Docker can be stopped using the container ID

$ docker stop 9baaa3824dea054a377f101044ca77ff66bc418eb033cabf68516e0c5ce16f73

I followed the process you describe.

It’s now cleared and up to date.

And above all I learned about a very reactive community which is so much enjoyable when starting out with HA. Thanks :pray:

2 Likes