问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/39801094/how-to-delete-an-image-from-a-private-docker-registry