containrrr / watchtower

A process for automating Docker container base image updates.
https://containrrr.dev/watchtower/
Apache License 2.0
19.71k stars 869 forks source link

REQUEST: label to cleanup images by container #1965

Open DeltaTangoLima opened 7 months ago

DeltaTangoLima commented 7 months ago

Is your feature request related to a problem? Please describe.

I have three use cases I want to use Watchtower for:

✅ Auto pull and notify only

✅ Auto pull, update containers, and notify

❌ Auto pull, update containers, cleanup old images, and notify

Describe the solution you'd like

I'm asking for consideration of a container-level cleanup option, using a boolean label such as com.centurylinklabs.watchtower.cleanup

Describe alternatives you've considered

Scripted cleanup of specific containers' older images, but that isn't terribly compatible with my how I manage my docker fleet (appx 30 hosts) using Portainer.

Ideally, I'd comb my Slack messages each weekend (Watchtower updates are cron'd for the early hours of Saturday morning), test the auto-updated containers, and only have to cleanup the two smaller groups of images as I go.

Additional context

Understand this may not be possible with a major rewrite of part of Watchtower. I haven't looked at the code myself, but I'm assuming the reason the cleanup option is host-wide is because Watchtower uses a docker prune to achieve it.

If so, then what I'm asking for would require individual assessment at a container level to determine which older images should and shouldn't be removed.