I created a docker image in the google cloudshell and I'm trying to push the image to the container registry but getting this error:

denied: Unauthenticated request. Unauthenticated requests do not have permission "artifactregistry.repositories.uploadArtifacts" on resource "projects/gcp-devops-415915/locations/us/repositories/gcr.io" (or it may not exist)

I have also tried the below step to login but still does not work for me:

gcloud auth print-access-token | docker login -u oauth2accesstoken --password-stdin https://us-central1-docker.pkg.dev

Is there some thing I am still missing? Can some one help me to figure out the issue?

I want to push a docker image to Google container registry by hitting below command:

docker push gcr.io/gcp-devops-415915/myfirstimage:v1.0

enter image description here

1

There are 1 best solutions below

0
James On

"Unauthenticated request" means you are not sending authentication to Artifact Registry. In this particular case, you are logging in to the wrong server.

gcr.io repos are hosted in the us multiregion, not in us-central1. You should also use the same host for login and push so the docker client is aware you are communicating with the same registry (You should use either gcr.io for both or us-docker.pkg.dev for both)