How can I delete a mistakenly added tag from an image in a private Docker registry? The option -rmi doesn't seem to work for remote images in Docker 1.9.1.
user@ubuntu-user:~$ docker --version
Docker version 1.9.1, build a34a1d5
user@ubuntu-user:~$ docker search myregistry:5000/user/image
NAME
myregistry:5000/user/image:20160119
myregistry:5000/user/image:20160119-20160120
user@ubuntu-user:~$ docker rmi myregistry:5000/user/image:20160119-20160120
Error response from daemon: could not find image: no such id: myregistry:5000/user/image:20160119-20160120
Error: failed to remove images: [myregistry:5000/user/image:20160119-20160120]
Best Answer
There seems to be no simple method to do remove images from the registry as of today and looks like its a feature for registry 2.1 milestone.
One of the options what we have today with this not working
is to manually remove it from the registry itself. Just to avoid removing wrong file accidentally, I tested it with this script from github. I take no guarantee on how this script works (though I checked it quickly before I tested it).
So, I made a test and that seems to work :)
[1] I presume that, you are running a registry with docker itself.
[2] I created a minimal Dockerfile with just
FROM alpine
content and created alpine:v1 and pushed to my private registry running on localhost:5000. Querying it from registry, it returned as expected.[3] Then I log into the registry with
docker exec
and checked the disk usage before I do my experiment[4] After returning back to my host I copied a heavy file (mongodb.tgz) into my container and created a built and pushed version v2.
[5] After checking the size again in the registry, it has increased to 62MB:
[6] In order to run
delete_docker_registry_image
, you need to get the script into the container which is hosting the registry, one option to do this is with curl. Also, this script requiresjq
.[7] Run the script, try with
--dry-run
option first and do not forget the version tag (v2 in this case), there is also a good-h
[8] And voila !!