【发布时间】:2021-03-17 08:04:24
【问题描述】:
通常,例如,对于 alpine 图像,我们通过以下方式获取身份验证令牌:
curl -i "https://auth.docker.io/token?service=registry.docker.io&scope=repository:library/alpine:pull"
然后我们可以使用它从注册表中获取清单:
curl -i -H "Authorization: Bearer $TOKEN" -H "Accept: application/vnd.docker.distribution.manifest.list.v2+json" https://registry-1.docker.io/v2/library/alpine/manifests/latest
当我们用我们的私有存储库(ourcompany/ourrepo)替换 library/alpine 时,获取令牌仍然有效,但是,下载清单会导致:
HTTP/1.1 401 Unauthorized
Content-Type: application/json
Docker-Distribution-Api-Version: registry/2.0
Www-Authenticate: Bearer realm="https://auth.docker.io/token",service="registry.docker.io",scope="repository:ourcompany/ourrepo:pull",error="insufficient_scope"
Date: Tue, 26 May 2020 10:32:56 GMT
Content-Length: 168
Strict-Transport-Security: max-age=31536000
{"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"repository","Class":"","Name":"ourcompany/ourrepo","Action":"pull"}]}]}
如何规避这个 401 错误?
我们需要获得额外的代币吗?另外发送身份验证凭据?做一些完全不同的事情?
【问题讨论】: