Home > front end >  How to delete images from an artifactory docker repo
How to delete images from an artifactory docker repo

Time:08-25

I have a docker repository in artifactory: artifactory.MYCOMPANY.com/artifactory/REPO-docker-local. I'd like to delete images in a periodic cron job. I have full permissions to create, delete and edit files on this artifactory repo.

I'd like to have a job that deletes ALL images once a month (to ensure the size doesn't grow too much, that's OK from the usage scenarios). However I can't find an API that would do that. I've tried docker rmi but it only deletes local images. What API could I use?

CodePudding user response:

Curl can make a DELETE request like below:

curl -u {username}:{password} -X DELETE https://artifactory.MYCOMPANY.com/artifactory/REPO-docker-local/TAG

This can delete many images at once, e.g. TAG:latest, TAG:1, ...

CodePudding user response:

This user plugin on clean Docker images might help in automating the deletion process by writing a script around the suggested curl command and setting up the script based on cronjob.

Note: For this plugin to work, the docker images getting deployed should have the LABEL mentioned in the user plugin.

  • Related