Migration of filesystem for docker

Hi,
i’m running home assistant on debian 10 with docker and supervisor. I have system on btrfs. I have noticed (and googled), that docker leaves lots of subvolumes of old docker images. I’m running out of space.

I have prepared clean XFS partition for /var/lib/docker. I can copy files from present /var/lib/docker.

But it won’t work after restarting docker, because it needs to have different structure. Is there a way to migrate? Will supervisor download everything (images) and (re)create containers for me?

Thanks for info.

When you update docker Image, old image remain in storage. This old image may simply be deleted if no longer needed/using. This would take care of “out of storage” problem.

If you delete the docker Image being used by docker Container I expect Container will not function. You should be able to rsync from /storagebrtfs to /storagexfs while disk not in use. But…How will docker know you move storage location/disk? Are you replacing drive or is this a separate mounted disk on system?

Ultimately, you could also delete all except docker persistent storage (like /ha/configfolder) and recreate the docker container and all should run as before.

Hi, problem is, docker keeps images as subvolumes on btrfs and forgets to clean up.

And it has different structure than on other filesystem.

On other computer, with xfs, i have images in /var/lib/docker/volumes , but on btrfs , there are subvolumes in /var/lib/docker/btrfs/subvolumes

you likely must also remove the brtfs storage driver support to eliminate the creation of subvolumes.

My point is in the end it is faster/simpler for you to recreate all Container after remove and reinstall docker
Docker is used for this exact purpose and I imagine you have less than 10 containers in your system. trying to copy/paste /var/lib/docker makes no sense and better to just recreate all containers after system has been prepared

Yes i have something like that in mind, hence my question, if hassio supervisor (re)creates all containers when it starts. I just don’t know, whether there is some information what and how should be set up, stored outside of docker, so it is set up again in the same way as it is now.

If i mount separate XFS to /var/lib/docker, i guess, the btrfs storage driver won’t kick in

So, it worked (almost) without problem. Just

systemctl stop  hassio-supervisor.service 
systemctl stop  docker.service 

mount new filesystem to /var/lib/docker

systemctl start  docker.service 
docker image pull homeassistant/amd64-hassio-supervisor
systemctl start  hassio-supervisor.service 

and it restored itself, without addons. I have to uninstall and install them by hand and restore config from backup, it is lost during uninstall