April 12, 2024

Periodic Reminder To Clean Up Your Docker Containers

<et cetera>

I attempted to install something on my Virtual Private Server (VPS) this morning. While cleaning things up (removing old software), I noticed my VPS was becoming exponentially sluggish by the second — I could not type anything or send any signals.

This ‘sluggishness’ had happened to me once before on another VPS when the memory became totally occupied. Back then, the kernel killed a process after a few minutes because it was out of memory, and I could ssh back in. Assuming the same would happen to the current VPS, I waited around ten minutes before realizing something was wrong. I decided to power off the VPS and restore a month-old snapshot.

Upon re-entry to the VPS, I investigated what was occupying so much memory. The answer: three-year-old docker containers that I completely forgot about. I tried setting up mailcow three years ago and forgot to nuke the many docker containers that came with it. It was occupying ~70% of my RAM! After killing all the docker containers, the server became noticeably more responsive.

So here’s your periodic reminder to clean up your docker containers.

</et cetera>