Generate a script to delete all images using the following. Copy paste into chrome console on the registry page of a project.
NOTE you must update the textToSave template string before running.
// Options(fill these out with your info)
// GITLAB_INSTANCE is the url to your custom instance or `gitlab.com`
const GITLAB_INSTANCE = 'gitlab.yourwebsite.com'
const GROUP = 'yourGroup'
const PROJECT = 'yourProjectSlug'
let images = []
$('.content-list tbody tr').each(function(index){
let image = $(this).find('td')[0].innerText
// Remove the space on the end.
image = image.slice(0,-1)
if (image.includes('-') && !image.includes('latest')) {
images.push(image)
}
})
console.log(`Found ${images.length} images`)
// Open chrome dev tools and go delete an image. Right click the request under the network tab and click "Copy as curl" then paste here.
// Replace the branch name in the url with `${branch}`
let textToSave = images.map(branch=> `curl 'https://${GITLAB_INSTANCE}.com/${GROUP}/${PROJECT}/container_registry/${branch}' //lots of headers`).join('\n')
let hiddenElement = document.createElement('a');
hiddenElement.href = 'data:attachment/text,' + encodeURI(textToSave);
hiddenElement.target = '_blank';
hiddenElement.download = 'remove-all-images.sh';
hiddenElement.click();
Run the script
cd ~/Downloads
chmod +x ./remove-all-images.sh
./remove-all-images.sh
Run garbage collection on registry then restart the registry.
docker exec gitlab gitlab-ctl registry-garbage-collect && docker restart gitlab
NOTE you have to restart the registry because the gc only removes the files, it doesn't notify the running registry to remove items from it's in memory cache.
AAaaa !
It is blowminding.
Thanks.
Are there any other "normal" solution for this problem?