Delete old images from registry


I am using a self hosted version of Gitlab.
Each time I am building a project I create a new docker image in the registry.
Now the images are taking a lot of space in my server, I would like to purge the old ones.
Is there any way to create a ci script which will be in all my projects take the 10 last built images, 10 last deploy to live and 5 last deploy to staging and erase the others ?

I already had a look to the api, I can easily list the projects from there, but I can not find all the CI and which one has been deployed, is there any way to do that ?
After it will be easy to get images versions and erase the others using docker-registry


Better tools for cleaning after builds are a highly requested feature, and something gitlab claims they are working on. I saved a number of bookmarks when we suddenly got huge problems (I mentioned them in one or two of the linked threads - and some of the bookmarks are about things that weren’t as critical for us, and were the threads were marked with milestones suggesting that a solution would come before things got critical here), but it’s been a while, so I don’t remember which are most interesting to you (looking at the titles I would guess at the last), so you will have to sort through this, but here are some links:

1 Like

I think that usage of such tools as Auslogics Registry Cleaner can help youto solve such a problem. I rememebr that I have uloaded the latest version here and use it till today to clean the registry. Also, I can suggest cclener but I think it’s better to clean the waste files and for registry cleaning you can use Auslogics. Both tools have the similar interface so it will not be hard for you to use them.