skip to Main Content

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?

2

Answers


  1. Chosen as BEST ANSWER

    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, ...


  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search