gcloud docker push 403 Forbidden

故事扮演 提交于 2019-12-01 17:31:03

问题


I am trying to push a docker image to eu.gcr.io and I am getting 403 Forbidden

gcloud docker push  eu.gcr.io/<projectname>/<image>:latest                                                                  
The push refers to a repository [eu.gcr.io/<projectname>/<image>] (len: 1)
663cd9de01fe: Preparing
Post https://eu.gcr.io/v2/w<projectname>/<image>/blobs/uploads/: token auth attempt for registry: https://eu.gcr.io/v2/token?account=_token&scope=repository%3A<projectname>%2F<image>3Apush%2Cpull&service=eu.gcr.io request failed with status: 403 Forbidden

I have checked

  1. curl https://eu.gcr.io/v1/_ping => works
  2. gcloud config list => project id is setup
  3. Storage api is enabled in console
  4. if I use the project name in the url I get 403 Forbidden
  5. if I use the project id in the url I get "Repository does not exist"
  6. gcloud auth list => shows the owner as active
  7. gcloud components update => All components are up to date.

回答1:


I had faced the same issue, to resolve it in order I done.

  1. Rename the images as told
  2. Add the user to docker group (important for the docker login)
  3. Use docker login token https://cloud.google.com/container-registry/docs/auth
docker login -e 1234@5678.com -u _token -p "$(gcloud auth print-access-token)" https://gcr.io 

(If using sudo docker, the token will be stored with the root account.)

Then use docker push gcr.io/projetc_id/imagename according to How to push a docker image to a private repository




回答2:


Looks like the problem is that the (local) docker tag was incorrect, the tag was the "project name" instead of "gcloud project id" so by changing the tag to contain the project the push works.



来源:https://stackoverflow.com/questions/34881697/gcloud-docker-push-403-forbidden

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!