Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcloud docker push 403 Forbidden

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.
like image 818
oluies Avatar asked Jan 19 '16 16:01

oluies


Video Answer


2 Answers

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 [email protected] -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

like image 79
Ali SAID OMAR Avatar answered Sep 19 '22 18:09

Ali SAID OMAR


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.

like image 44
oluies Avatar answered Sep 20 '22 18:09

oluies