About moving docker to an external SSD

Hi all.

I’m new in docker and I’m using it to set up an immich server in my raspberry pi 5. I have installed the raspi OS in a 32 gb microsd that was running out of free space really fast due to overlay files. So, I read a guide to move docker files to the external ssd’s I’m using for photography storage (editing a json file) and now I have a couple questions.

The overlay files in /var/lib/docker/overlay2 (in theory old ones from the previous docker location) are occupying about 8Gb data and I would like to know if I can remove from the system and how to do it safely. Theoretically, the new docker files are in the external ssd.

As well, in the file manager, have appeared somehow “merged” units that belong to docker overlay files as well. Does anyone knows what is this? (please, see screenshot)

Thanks a lot in advance.

What you see in the filemanager can be filemanager specific. Since an overlay filesystem means multiple folders are merged as multiple layers, you could see those as “merged”. You can search for some filemanager settings to disable those kind of “devices” appearing.

If you run docker info that shows if you are really using a new docker data root. If you are, you can safely delete the old folder any way you like. It also depends on how you moved the data root to the external disk. If you recreated the whole docker data root and pulled all images and created all containers there, there is nothing pointing to the old folders. If you copied the data to the new disk, and you deleted al containers before that to move only the image layers, deleting the old folder should be fine. But we can say more only if you share more about how you moved the docker data root exactly. Just by changing a json no data is copied so you would have a completely new docker data root.

Thanks a lot!!

I followed this link first shutting down docker and pulling it again afterwards. Using docker info, docker root directory now is the one I wanted in the ssd. The only thing that links to a different folder is the CDI specs directory (still to /var/run/cdi and /etc/cdi.

Before moving Docker, I would check why the Docker folder is growing. It could be unused (outdated) images, which could be pruned to save space. It could be files written inside the container, which I would avoid.

For me a container is always throw-away, everything should be stored outside. We mount config and documents folders via bind mount, so they are external to the container, can not be accidentally deleted when removing or re-creating the container, are easier to backup.

Just as some food for thought.

But maybe it’s a good idea to move to the external SSD drive, it might be faster than the internal SD.

2 Likes

First of all, @bluepuma77 has a good point regarding growing size of used space, but I will focus on the original question assumig you know why the extra space was required.

So the linked guide is mostly right, but it also has some big errors. Fotunately those are not relevant to your issue, but it confuses yaml syntax with json and some docker-related folders.

The important tpart is that you stopped Docker, changed the config to use a new data root and pulled everything into the new data root.

So I think the only thing that you might need is the content of the original volumes folder (/var/lib/docker/volumes). Only if you had saved data on the volumes like databases. If you bind mounted everything from other directories, the previous Docker data root can be safely deleted, especially if you see the applications work perfectly in the new environment. Just to be safe, you can make a backup of the original data root, just in case anything is needed from that later. If it is not needed for a certain time you decide, you can delete the backup too.

1 Like