Have you ever wondered how to remove repositories/tags from your private Docker registry? It's simple according to Docker registry API specs. So let's try this
yum -y install docker-registry sudo systemctl start docker-registry docker pull fedora:21 docker tag fedora:21 localhost:5000/fedora:21 curl localhost:5000/v1/repositories/fedora/tags/21
You should see an image id printed to your terminal. Now let's delete the image...
$ curl -X DELETE localhost:5000/v1/repositories/fedora/tags/21 true
To be clear - it does not remove the image/layers data - it just removes the reference from fedora:21 tag to the image id (i.e. data). If there is any other tag referencing the data, they will still be accessible.
Anyway, in some cases it is useful to be able to remove this reference. I run a private registry with 337 images (multiplied by few tags for every image) and I sometimes found myself in a situation where I pushed an image with wrong tag or I just wanted to stop people from pulling a specific image. I wrote a small bash script for these occasions - drrm.sh. The usage is simple
Which means for our fedora example
$ ./drrm.sh localhost:5000/fedora:21 Do you really want to untag "834629358fe214f210b0ed606fba2c17827d7a46dd74bd3309afc2a103ad0e89"? [y/N]: y Image library/fedora:21 removed from localhost:5000
Firstly it checks if the image exists, then it asks for confirmation of removal and then it calls the previously shown curl command to delete the reference. I also have a simple "Docker Registry Garbage Collector" under development which goes through the docker-registry directory and moves unreferenced layers away (where you can delete them later). But that's going to be a topic next time:).