Config folder out of sync between host and container file system

I’m running a container installation on Ubuntu and am having a strange issue.

I recently installed HACS by running the install script inside the container. I was having all sorts of trouble getting it configured, so I looked inside the custom_components directory in my home folder and found it was empty. I was baffled, so I ran bash inside the container (sudo docker exec -it <id> bash) and found the custom_components directory had the expected content. I also noticed that the configuration.yaml file inside the container was an older version that didn’t reflect recent changes I’d made.

I checked the mount bindings and everything was correct. Then I made a big mistake: I restarted the container in hopes that it would sync its file system to my host file system, but the opposite happened. The outdated configuration folder on the host system was synced to the container, and I lost nearly all of my configuration.

I know my configuration is almost certainly lost for good, which is super demoralizing. But what caused the out-of-sync behavior in the first place? How can I avoid it, or fix it correctly if it happens again?

Likely, at some point they were not, and the changes you were doing were done in the container itself.
Unless you killed the container (“docker rm”), you possibly can get back your config by not doing the bind mount, then copying back the config with “docker cp”.

Ah, ok. So if I’m thinking about the process correctly:

  • stop container
  • remove mount binding
  • start container
  • copy /config from the container onto local fs
  • add mount binding again

The strange thing is that before I lost my config I did try “docker cp”, but the files that got copied were not the ones that I could see from a terminal inside the container. Maybe because the mount was still there?

Thanks for the help!