7

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.
aknuds1
  • 65,625
  • 67
  • 195
  • 317
oluies
  • 17,694
  • 14
  • 74
  • 117
  • maybe similar or duplicate http://stackoverflow.com/questions/31235586/google-container-registry-access-denied-when-pushing-docker-container – oluies Jan 19 '16 at 16:30

2 Answers2

3

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.

oluies
  • 17,694
  • 14
  • 74
  • 117
  • yeah, had the same problem. I scanned over https://cloud.google.com/container-registry/docs/pushing too fast; they really want you to name your local docker containers in a specific format or else you can't push. Also worth noting that the id must be a name, not the number sequence. Once I figured all that out pushing was a-ok haha – Yoshua Wuyts Aug 17 '16 at 15:15
3

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

Community
  • 1
  • 1
Ali SAID OMAR
  • 6,404
  • 8
  • 39
  • 56