Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to "delete" an image from a private Docker Registry?

I'm writing an API client for docker and the registry API is difficult to work with. I'm trying to delete an image from the registry however I keep getting this error

[ { code: 'UNSUPPORTED', message: 'The operation is unsupported.' } ]

My steps to get this are as follows,

 >  GET http://localhost:5000/v2/
  >  registry/2.0
 >  registry/2.0
 >  GET http://localhost:5000/v2/_catalog/
  >  { repositories: [ 'alpine' ] }
 >  GET http://localhost:5000/v2/alpine/tags/list
  >  { name: 'alpine', tags: [ 'latest' ] }
 >  HEAD http://localhost:5000/v2/alpine/manifests/latest
  >  sha256:df73ed0973f15f40496c148330f9b559f0a5583c03f6ac8d26adadf6f4690aff
 >  DELETE http://localhost:5000/v2/alpine/manifests/sha256:df73ed0973f15f40496c148330f9b559f0a5583c03f6ac8d26adadf6f4690aff
[ { code: 'UNSUPPORTED', message: 'The operation is unsupported.' } ]

EDIT

I'm updating my question since I found the REGISTRY_STORAGE_DELETE_ENABLED variable.

I now run the registry container like so,

docker run -d -p 5000:5000 -e REGISTRY_STORAGE_DELETE_ENABLED=true --name registry2 registry

Which produces a new error,

[ { code: 'MANIFEST_UNKNOWN', message: 'manifest unknown' } ]

Clearly the UNSUPPORTED error, really meant that the particular feature was disabled.

However everything I read says that deleting the manifest's entity reference (the digest from the HEAD request) should remove the repository. I just want to make a repository in my private registry unreachable, I consider that deleted.

How do I delete an image from a private registry, such that it may not be pulled?

like image 525
Aage Torleif Avatar asked Sep 30 '16 22:09

Aage Torleif


People also ask

How do I remove a docker image from a private repository?

In order to pull images from your private repository, you'll need to login to Docker. If no registry URI is specified, Docker will assume you intend to use or log out from Docker Hub. Triton comes with several images built-in. You can view the available list with triton images .

How do I remove unwanted docker images?

If we do not want to find dangling images and remove them one by one, we can use the docker image prune command. This command removes all dangling images. If we also want to remove unused images, we can use the -a flag. The command will return the list of image IDs that were removed and the space that was freed.

Where does private docker registry store images?

This is stored within /var/lib/docker on the docker host, probably under a container or overlay sub directory, and then under a unique directory name per container. And then that, within Docker Desktop on Mac, is within a VM.

How do I remove a container from the registry?

Go to the Container Registry page. Click on the image name to see version(s) of that image. In the registry, check the box next to the version(s) of the image that you want to delete. Click DELETE on the top of the page.


1 Answers

Even if this is an old question: The solution is simple.

DELETE http://localhost:5000/v2/alpine/manifests/sha256:df73ed0973f15f40496c148330f9b559f0a5583c03f6ac8d26adadf6f4690aff

is wrong because the digest is prefixed with sha256:. Simple remove the prefix and then a delete is possible:

DELETE http://localhost:5000/v2/alpine/manifests/df73ed0973f15f40496c148330f9b559f0a5583c03f6ac8d26adadf6f4690aff
like image 127
Uwe Plonus Avatar answered Oct 18 '22 10:10

Uwe Plonus