How do I manage the size of /var/lib/containerd while using Docker?
Asked by
MAY_I_ask
I've been diving into containerization for a while, and I recently set up an older server to host some containers. I used the Docker installation guide to set it up with Debian Trixie, and I redirected Docker's files to "/home/docker" to prevent my "/var" partition from filling up. However, I noticed that "/var/lib/containerd" has ballooned to several GBs, which is quite a change from my previous server where it was just around 1MB. I ran into an error about "no space left on device" while moving containers, and after troubleshooting with a clean reinstall of Docker, the "/var/lib/containerd" size shrank briefly but then began to grow again dramatically after a "docker compose pull". I'm looking for advice on effectively managing "/var/lib/containerd"โideally, I'd like to redirect it as wellโas well as resolving the "No such container" error that popped up. Any insights would be appreciated!
Answers
Youโre facing this because since Docker v29, containerd has become the default storage backend for images instead of the older graph drivers. In the past, you might not have needed to manage the containerd directory since it didnโt use much space. Now that itโs gaining more importance, redirecting it like you did for Docker is essential to avoid filling up your partitions!
Reply to this answer
It's a common issue! The thing to know is that Docker's data-root setting only affects Dockerโs own storage, while containerd still defaults to using "/var/lib/containerd". To redirect it, first stop both Docker and containerd services. Then, you can set up a config file at "/etc/containerd/config.toml", changing the root path from "/var/lib/containerd" to something like "/home/containerd". After moving the existing data, restart the services. This should help manage your space better! As for the 'No such container' message, it usually happens when Docker and containerd become out of sync because of partial installs or running out of space. A clean fix is to remove the directories for both Docker and containerd and reinstall them, making sure to configure the paths correctly. Once that's all set, everything should run smoothly!
flute_repair: Thanks for the tips! I followed your steps and it really sorted out my space issues. I just had to modify my '/etc/containerd/config.toml' and everything's back to normal.
Reply to this answer
Add your answer
Answers are reviewed before publication.
yarn_dye_lot: Exactly! This explains why I never had to mess with containerd either. Thanks for clarifying!