Not to my knowledge, but you can set up a cron job to prune containers older than X days.
Selfhosted
A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.
Rules:
-
Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.
-
No spam posting.
-
Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.
-
Don't duplicate the full text of your blog or github here. Just post the link for folks to click.
-
Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).
-
No trolling.
Resources:
- selfh.st Newsletter and index of selfhosted software and apps
- awesome-selfhosted software
- awesome-sysadmin resources
- Self-Hosted Podcast from Jupiter Broadcasting
Any issues on the community? Report it using the report flag.
Questions? DM the mods!
Yeah, I found the docker system prune filter option in the docs as well. Very unprecise sadly but thanks for mentioning it. :) I'm thinking of something like "when updating, first copy the version number of the old image and exclude it from prune". Probably going to have to write something myself again. Feel free to spitball with me.
So my thought with the time based pruning is that you can keep a backup that's X days old.
Let's say you keep 2 weeks. If there have been no problems with an image after 2 weeks of an update, you're probably good to go. If you have an issue during those 2 weeks, you can return to and image within those 2 weeks. If you've had no problems after 2 weeks, it's probably stable.
Adjust 2 weeks to whatever you're comfortable with.
This would absolutely make sense, were it not for the fact that the old image can be 3 weeks old when the new one comes out. Feel free to correct me but I think a time based option on age is not sufficient.
Correct, that would not work for that case.
But thanks for suggesting and spitballing with me.
Not to sound flippant, but it seems like a solution looking for a problem. I use the --cleanup flag, and if there's an issue, rolling back is as simple as changing dockerimage:latest to dockerimage:version that worked.
Unless I'm missing something.
Pretty much this. I don't even bother with watchtower anymore. I just run this script from cron pointed at the directory I keep my directories of active docker containers and their compose files:
#/bin/sh for d in /home/USERNAME/stacks/*/ do (cd "$d" && docker compose pull && docker compose up -d --force-recreate) done; for e in /home/USERNAME/dockge/ do (cd "$e" && docker compose pull && docker compose up -d --force-recreate) done;
docker image prune -a -f
I agree. If OP is scared that the image creator is clearing the old images, then OP should just mirror the registry or just have a system backup.
Not exactly what you're asking but you can push specific images to a private repo to keep specific versions... Then you can just use the cleanup tag or prune to clear them off the system and if you want to pull them again it won't need to download it from the internet
Hmmmm… thats pretty cool. Thanks for the suggestion.