Search code examples
dockergoogle-cloud-platformdocker-imagegoogle-artifact-registry

Pushing image to Artifact Registry returning 403 Forbidden Error


I have limited experience working with Google Cloud so please bear with me. After attempting to push an image to Artifact Registry using docker push <repo-tag> command but I am getting the following error:

failed to authorize: failed to fetch anonymous token: unexpected status from GET request to https://<region>-docker.pkg.dev/v2/token?scope=repository%3A<repo-name>%2F<repo-name>%2Fpkg%3Apull&scope=repository%3A<repo-name>%2F<repo-name>%3Apull%2Cpush&service=<region>-docker.pkg.dev: 403 Forbidden

I am signed in as the owner (yes I know it's bad practice) so I should have permission to push to the registry. I've already gcloud auth login to authorize my user account and gcloud auth print-access-token returns a token for my account. Furthermore I've also pushed to Docker Hub and didn't get any issues so the problem isn't with Docker.

If anyone is able to shed some light as to why I am getting this error, I would greatly appreciate it.


Solution

  • Oddly enough, I realized that Artifact Registry was not properly configured locally. I had to add gcloud auth configure-docker <region>-docker.pkg.dev to specify the region configuration