9

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?

Community
  • 1
  • 1
Aage Torleif
  • 1,907
  • 1
  • 20
  • 37
  • There are still a lot of issues with this. I didn't try it recently but some time ago it worked for me. This issue could be useful: https://github.com/docker/docker-registry/issues/988#issuecomment-249532002 – lvthillo Oct 04 '16 at 11:53
  • I think, that this is the exactly same thing, can you check? http://stackoverflow.com/questions/39918794/cant-delete-docker-image-from-registry/39942620#39942620 – Evedel Oct 09 '16 at 10:44
  • 1
    Yes/No, it's a little different. For me the solution was found in this issue, https://github.com/docker/distribution/issues/1831 Basically the HEAD request to get the correct digest grabs a digest from the V1 schema instead of the V2 schema. To get the V2 schema, and the correct digest, a specific header must be set in the HEAD request. BTW, GET requests work as-well and return the layer digests which should be deleted as well. – Aage Torleif Oct 13 '16 at 11:58

1 Answers1

2

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
Uwe Plonus
  • 9,803
  • 4
  • 41
  • 48