Daniel Porteous
Daniel Porteous

Reputation: 6333

Auth error when pushing to Google Artifact Repository

I'm trying to push to GAR from my local machine, but I always get this error:

failed to authorize: failed to fetch anonymous token: unexpected status: 403 Forbidden

First, I've confirmed that my account has the Artifact Registry Writer role through IAM.

I have done the following locally:

# Login with my Google account
gcloud auth login --update-adc --force

# Configure docker to use the gcloud CLI auth helper
gcloud auth configure-docker us-west1-docker.pkg.dev

# docker login for good measure
docker login

# Tag my image (already built)
docker tag myimage us-west1-docker.pkg.dev/myproject/myrepo/myimage

# Push it
docker push us-west1-docker.pkg.dev/myproject/myrepo/myimage

On this final command I get the error above.

I have read all the Google documentation I could find but they all suggest the above steps:

Note: I can't pull either, using the command provided directly from the GCP web UI.

I'm on M1 Mac.

Upvotes: 1

Views: 5028

Answers (1)

Daniel Porteous
Daniel Porteous

Reputation: 6333

So I was able to solve this problem by completely nuking Docker, specifically with these steps: https://stackoverflow.com/a/69437543/3846032. I couldn't uninstall it by normal means, it would just hang, implying that the problems I was getting were a result of my Docker installation being very broken. Indeed, I managed to follow the above steps on another machine and it worked, which led me to conclude the steps above and my credentials were totally fine.

The 403 was a red herring, it must have come from my local Docker being broken in such a way that it doesn't send properly authenticated requests.

Upvotes: 1

Related Questions