artifactory-user-plugins icon indicating copy to clipboard operation
artifactory-user-plugins copied to clipboard

Docker cleanup plugin

Open sushant-pradhan opened this issue 5 years ago • 3 comments

It will be good to have docker images cleanup in line with the artifactCleanup plugin. Basically allow deletion on docker images based on last download date.

Inspired from a standalone script: https://jfrog.com/knowledge-base/how-to-clean-up-old-docker-images/

sushant-pradhan avatar Sep 24 '20 23:09 sushant-pradhan

Hi! Have you tried this one? https://github.com/jfrog/artifactory-user-plugins/tree/master/cleanup/cleanDockerImages

DarthFennec avatar Sep 25 '20 00:09 DarthFennec

Hey @DarthFennec yes I did. The plugin unfortunately is not as good as artifactCleanup plugin for 2 reasons:

  • It needs a build time label/property to be set/passed. This is not always possible if you have multiple CI systems or process pushing images
  • The approach of deleting images based on download date looks to be most apt (instead of just deleting by count as the cleanDockerImages does). The jfrog blog covers the approach well and in fact dockerhub is also implementing similar approach for cleaning up inactive images: https://www.docker.com/pricing/resource-consumption-updates

sushant-pradhan avatar Sep 25 '20 02:09 sushant-pradhan

It needs a build time label/property to be set/passed. This is not always possible if you have multiple CI systems or process pushing images

That's what it says on the tin yet not exactly how it works.

If you apply one or both properties on manifest.json file, it works just as well:

docker.label.com.jfrog.artifactory.retention.maxCount
docker.label.com.jfrog.artifactory.retention.maxDays

Granted, one can consider this a "hack".


Generally and IMO: baking in the property as a Docker label is not great for a few reasons. This data is immutable, which means:

  • you can't have different retention policies between repositories which is typical when using image promotion
    • e.g. as a product manager, I would like to set retention of 1 month for a docker-dev repository but the same image - if promoted to docker-production - should be kept for min. 2 years
  • you can't reliably "pin" a specific image to not be deleted
  • not a big deal yet ... it exposes internal information (i.e. that you're internally a user of Artifactory) within the public artifacts you'd make available to the customers

weakcamel avatar Nov 24 '21 15:11 weakcamel