Here is a very simple requirement. I prepared a docker image on my Mac and wish to push it to GCR. Tried below steps..
gcloud auth configure-docker
docker login gcr.io
docker push gcr.io/[project-id]/gcloud:latest
The push refers to repository [gcr.io/[project-id]/gcloud]
0141ab2d5898: Retrying in 1 second
522a3d37badb: Retrying in 1 second
0b1ee8a19f71: Retrying in 1 second
0cb89ac95352: Retrying in 1 second
c27a33c2a613: Retrying in 2 seconds
1416f891501a: Waiting
2edebac67fd2: Waiting
cff7468ca6ac: Waiting
7d105a69bdfc: Waiting
8607e6c66303: Waiting
dc87e12495f4: Waiting
c3c5e6948ef3: Waiting
5f70bf18a086: Waiting
b2f56e492d5b: Waiting
861512eb6ef5: Waiting
876201329b4b: Waiting
unknown: Token exchange failed for project '[project-id]'. Bad Request.
Does anybody can suggest on this issue?
Did you try gcloud auth activate-service-account [SERVICE_ACCOUNT]
instead docker login gcr.io
I think it is a better way than docker login
.
I had the same problem with the added precondition that there was not yet an existing image in the registry.
If no image exists yet, the GCR storage backend (a GCS bucket) also doesn't exist yet.
Make sure that this bucket can be created by the user that's logged into gcloud
. In my case, there was an org policy prohibiting multi-region buckets, which is the type of bucket that's needed for GCR.
You can check if this is the root cause of your issue by going into the project activities, where you'll see a failing bucket creation.