本文介绍了如何“删除”来自私有Docker Registry的映像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为docker编写API客户端,因此很难使用注册表API。我正在尝试从注册表中删除图片,但是我一直收到此错误

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.' } ]


编辑


由于我发现 REGISTRY_STORAGE_DELETE_ENABLED 变量。

我现在像这样运行注册表容器,

I now run the registry container like so,

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

这会产生新错误,

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

显然是 UNSUPPORTED 错误,确实意味着该特定功能已被禁用。

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

但是我读到的所有内容都表明删除清单的实体引用(来自HEAD请求的摘要)应删除存储库。我只是想使私有注册表中的存储库无法访问,我认为已将其删除。

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.

推荐答案

即使这是一个老问题:解决方案也很简单。

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

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

是错误的,因为摘要以 sha256:为前缀。简单地删除前缀,然后可以删除:

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

这篇关于如何“删除”来自私有Docker Registry的映像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 21:32