My organization is facing issues with high disk utilization on our container registry every few months. We've typically opted to just add more space, but it feels like we're not addressing the root problem: cleaning up old, unused, or stale images. I'm considering a policy to delete images older than 12 months, but our developers have voiced concerns, claiming they don't build images frequently enough. However, I believe that with a robust continuous integration setup, removing outdated images shouldn't pose a significant issue. Additionally, our current images aren't optimized and are quite large, which is exacerbating the storage problem. Is this resistance a sign of organizational inertia, or are there better ways to optimize our registry's image lifecycle? What best practices should we adopt?
5 Answers
You might want to consider keeping at least the five newest images while also implementing a time-based cleanup. This way, you retain recent images without holding onto too many outdated ones.
I tend to delete anything that's not been downloaded for a while, but I always keep the latest five versions. It's unlikely anyone will need to roll back more than four versions after some time has passed, so this method works for us.
In our setup, we do a cleanup every week. It keeps things manageable without worrying about stale images piling up.
Rebuilding images isn't always straightforward. Sometimes the necessary versions aren't available, and it can complicate things. Just keep that in mind while discussing your cleanup strategies.
Looks like you're dealing with a couple of issues: your developers think that rebuilding images is difficult (it isn’t), and you’ve got some seriously huge images. I’d suggest starting with the size issue first. Have your team check the size of one of those massive images by running `docker history`. They'll likely find they're installing way more than needed. Using multi-stage builds and avoiding caching at `/var/cache/apt` can save much more space than just deleting old images, and it will help avoid any pushback in the future.

Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures