I am working on a bitbucket pipeline for pushing image to gc container registry. I have created a service account with Storage Admin role. (bitbucket-authorization@mgcp-xxxx.iam.gserviceaccount.com)
gcloud auth activate-service-account --key-file key.json
gcloud config set project mgcp-xxxx
gcloud auth configure-docker --quiet
docker push eu.gcr.io/mgcp-xxxx/image-name
Although that the login is successful, i get: Token exchange failed for project 'mgcp-xxxx'. Caller does not have permission 'storage.buckets.get'. To configure permissions, follow instructions at: https://cloud.google.com/container-registry/docs/access-control
Can anyone advice on what i am missing?
Thanks!
These are step-by step commands which got me to push first container to a GCE private repo:
GCR just uses GCS to store images check the permissions on your artifacts. folder in GCS within the same project.
For anyone reading all the way here. The other suggestions here did not help me, however I found that the Cloud Service Build Account role was also required. Then the
storage.buckets.get
dissappears.This is my minimal role (2) setup to push docker images:
The Cloud Service Build Account role however adds many more permissions that simply
storage.buckets.get
. The exact permissions can be found here.note: I am well aware the Cloud Service Build Account role also adds the
storage.objects.get
permission. However, addingroles/storage.objectViewer
did not resolve my problem. Regardless of the fact it had thestorage.objects.get
permission.If the above does not work you might have the wrong account active. This can be resolved with:
If that does not work you might need to set the docker credential helpers with:
On one final note. There seemed to be some delay between setting a role and it working via the
gcloud
tool. This was however minimal, think of a scope less than a minute.Cheers
Tried several things, but it seems you have to run
gcloud auth configure-docker
add service account role
on google cloud IAM
Editor Storage object Admin Storage object Viewer
fix for me
You need to be logged into your account and set the project to the project you'd like. There is a good chance you're just not logged in.
gcloud auth login
gcloud config set project <PROJECT_ID_HERE>