我正在尝试从我的私有注册表中GET一个清单v2,并在不同的标签下对其进行PUT。我是用Python语言写的实用程序(requests库)来做的。
如果我将所需图像清单保存到JSON文件中,然后执行curl命令:
curl -XPUT 'http://localhost:5000/v2/<repository>/manifests/latest' -H 'content-type: application/vnd.docker.distribution.manifest.v2+json' -d @manifest.json它的工作和响应速度为2xx。但是如果我尝试用Python来做这件事:
manifest = requests.get(url='http://localhost:5000/v2/%s/manifests/%s' % (img, tag),
headers={'Accept': 'application/vnd.docker.distribution.manifest.v2+json'})
put_latest = requests.put(url='http://localhost:5000/v2/%s/manifests/latest' % image,
headers={'Accept': 'application/vnd.docker.distribution.manifest.v2+json'},
data=manifest.text)它只是使用400 Bad Request和{'errors': [{'code': 'MANIFEST_INVALID', 'message': 'manifest invalid', 'detail': {}}]}进行响应,而在docker-registry日志中显示为err.detail="missing signature key"。
我做错了什么?
发布于 2021-07-23 03:41:12
我发送了错误的标题键。我想我应该使用Content-Type而不是用于GET的Accept。
manifest = requests.get(url='http://localhost:5000/v2/%s/manifests/%s' % (img, tag),
headers={'Accept': 'application/vnd.docker.distribution.manifest.v2+json'})
put_latest = requests.put(url='http://localhost:5000/v2/%s/manifests/latest' % image,
headers={'Content-Type': 'application/vnd.docker.distribution.manifest.v2+json'},
data=manifest.text)https://stackoverflow.com/questions/68488419
复制相似问题