我正在尝试获取Docker集线器的目录列表,但到目前为止,我只是在响应中遇到错误。我的理解是,我需要在目录请求中传递一个承载令牌,因此我首先要获得具有相关范围的令牌:
curl -u "username:password "https://auth.docker.io/token?service=registry.docker.io&scope=registry:catalog:*"
(这是使用我的Docker Hub帐户中的用户名/密码)
然后,我将返回的令牌传递给注册表:
curl -vL -H "Authorization: Bearer eyJhbGciOiJFUzI1NiIsInR5cCI6I(...)" https://registry-1.docker.io/v2/_catalog
响应该请求,我得到:
* Trying 54.86.130.73... * Connected to registry-1.docker.io (54.86.130.73) port 443 (#0) * TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 * Server certificate: *.docker.io * Server certificate: RapidSSL SHA256 CA - G3 * Server certificate: GeoTrust Global CA > GET /v2/_catalog HTTP/1.1 > Host: registry-1.docker.io > User-Agent: curl/7.43.0 > Accept: */* > Authorization: Bearer eyJhbGciOiJFUzI1NiIsInR5cCI6I(...) > < HTTP/1.1 401 Unauthorized HTTP/1.1 401 Unauthorized < Content-Type: application/json; charset=utf-8 Content-Type: application/json; charset=utf-8 < Docker-Distribution-Api-Version: registry/2.0 Docker-Distribution-Api-Version: registry/2.0 < Www-Authenticate: Bearer realm="https://auth.docker.io/token",service="registry.docker.io",scope="registry:catalog:*",error="insufficient_scope" Www-Authenticate: Bearer realm="https://auth.docker.io/token",service="registry.docker.io",scope="registry:catalog:*",error="insufficient_scope" < Date: Fri, 06 May 2016 23:00:08 GMT Date: Fri, 06 May 2016 23:00:08 GMT < Content-Length: 134 Content-Length: 134 < Strict-Transport-Security: max-age=31536000 Strict-Transport-Security: max-age=31536000 < {"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"registry","Name":"catalog","Action":"*"}]}]}
…这似乎要求我返回并获得我在上面输入的网址的授权。
应该可以吗?如果是这样,我想念什么?
我遇到了同样的问题,在docker支持下提出了这个问题,并得到以下答案:“目录端点不适用于Docker Hub,因为该端点实际上列出了注册表上的所有存储库,并且我们将其禁用,因为它将列出所有存储库。 Docker Hub。”