docker registry v2和curl的insufficient_scope错误

我试图通过v2registry访问docker中心,无法理解为什么我得到一个在headers中返回的insufficient_scope错误。

 #!/bin/bash REPO=ubuntu TAG=latest REGISTRY=https://registry-1.docker.io/v2 URI="$REGISTRY/$REPO/manifests/$TAG" echo URI=$URI MANIFEST="`curl -skL -o /dev/null -D- $URI`" CHALLENGE="`grep "Www-Authenticate" <<<"$MANIFEST"`" if [[ CHALLENGE ]]; then IFS=\" read _ REALM _ SERVICE _ SCOPE _ <<<"$CHALLENGE" echo REALM is $REALM echo SERVICE is $SERVICE echo SCOPE is $SCOPE TOKEN="`curl -skL "$REALM?service=$SERVICE&scope=$SCOPE"`" IFS=\" read _ _ _ TOKEN _ <<<"$TOKEN" echo TOKEN is $TOKEN MANIFEST="`curl -isk -X GET -H "Authorization: Bearer $TOKEN" $URI`" echo "RESPONSE is $MANIFEST" fi 

控制台输出是:

 URI=https://registry-1.docker.io/v2/ubuntu/manifests/latest REALM is https://auth.docker.io/token SERVICE is registry.docker.io SCOPE is repository:ubuntu:pull TOKEN is eyJhbGciOiJFUzI.eyJhY2Nlc3MiOltdLCJhdWQiOiJyZWdpc3RyeS5kb2NrZXIuaW8iLCJleHAiOjE0NjgyNTU4ODgsImlhdCI6MTQ2ODI1NTU4OCwiaXNzIjoiYXV0aC5kb2NrZXIuaW8iLCJqdGkiOiJBc2R5ZzBiX0hnNlNDS2Z0MEgtMiIsIm5iZiI6MTQ2ODI1NTU4OCwic3ViIjoiIn0.6pCh0OIabGGbBd8mubOpwlighlX69P7tMFqGk5P-knsJqxw7-G9YzaY-5_gUKRb44NvaJAeib84EYa0AejbUSw RESPONSE is HTTP/1.1 401 Unauthorized Content-Type: application/json; charset=utf-8 Docker-Distribution-Api-Version: registry/2.0 Www-Authenticate: Bearer realm="https://auth.docker.io/token",service="registry.docker.io",scope="repository:ubuntu:pull",error="insufficient_scope" Date: Mon, 11 Jul 2016 16:46:31 GMT Content-Length: 138 Strict-Transport-Security: max-age=31536000 {"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"repository","Name":"ubuntu","Action":"pull"}]}] 

回声是我所期望的,所以我目前很难过。

我只能在谷歌上发现这张票,但是并没有说明我的情况。

对于任何遇到这篇文章的人来说,问题似乎是没有ubuntu存储库(至less不公开)。 用REPO=library/ubuntu代替似乎解决了它。

Interesting Posts