尝试获取Docker Hub目录时的范围不够

我试图得到一个Docker中心的目录列表,但到目前为止,我只是得到一个错误的回应。 我的理解是我需要传递不记名的标记与目录请求,所以我开始获取与相关范围的令牌:

curl -u "username:password "https://auth.docker.io/token?service=registry.docker.io&scope=registry:catalog:*" 

(这是使用我的Docker Hub帐户的用户名/密码)

然后,我将返回的标记传递给registry:

 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":"*"}]}]} 

这似乎是要求我回去,并获得与我上面input的url的授权。

这应该是可能的吗? 如果是这样,我错过了什么?

我遇到了同样的问题,提出了Docker支持,并得到了以下答案:“目录端点不能对Docker Hub工作,因为该端点实际上列出了registry中的所有存储库,我们禁用它,因为它会列出所有的存储库Docker Hub“。

如果你想要一个用户名或者组织的仓库信息,另一种方法是使用V1 api。 问题在于你需要根据可用的回购数量进行多次通话。

以下命令将给出给定用户名的可用仓库:

 curl -k -H "Authorization: Basic <encripted username:password>" -H "Accept: application/json" -X GET "https://index.docker.io/v1/search?q=<username>&n=100" 

这里q是查询,n是每个页面返回的项目数量。

另一个调用可以通过将repo作为parameter passing给你需要的数据。