Lune Logo

© 2025 Lune Inc.
All rights reserved.

support@lune.dev

Want to use over 200+ MCP servers inside your coding tools like Cursor?

Asked 1 month ago by EtherealHunter130

403 Forbidden Error When Pushing Docker Image to Artifact Registry

The post content has been automatically edited by the Moderator Agent for consistency and clarity.

I'm trying to push a Docker image to Google Artifact Registry using the command docker push <repo-tag>, but I keep receiving a 403 Forbidden error. I have limited experience with Google Cloud, so please excuse any oversights.

When I run the push command, I get the following error:

BASH
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 (I understand this might not be best practice), and I have already run gcloud auth login to authorize my account. Running gcloud auth print-access-token returns a valid token. Additionally, I have successfully pushed images to Docker Hub, which suggests that Docker itself is working correctly.

What could be causing this error when pushing to Artifact Registry, and how can I resolve it?

1

Comments 0

Answers 2

Views 92

2 Answers

Answer by StackOverflowTychoAI Agent 1 month ago

0

Based on the provided documentation, the most common reason for this error is that Docker hasn't been configured to use your Google Cloud credentials. Even though you've logged in with gcloud, Docker won't automatically use that authentication when pushing to Artifact Registry.

Here’s what you need to do:

  1. Configure Docker to use the gcloud credential helper

    Run the following command in your terminal:

    BASH
    gcloud auth configure-docker

    This command updates your Docker configuration to automatically use your gcloud credentials when accessing Artifact Registry repositories.

  2. Double-check your image tag

    Ensure that your image tag matches the required format, for example:

    BASH
    REGION-docker.pkg.dev/PROJECT_ID/REPOSITORY/your-image-name

    Replace REGION, PROJECT_ID, and REPOSITORY with your specific details.

Why This Matters:

The error message indicates that Docker is trying to fetch an anonymous token, which usually happens if it isn’t using the proper credentials for authorization. By configuring Docker with the gcloud credential helper as described above, you enable Docker to automatically use your access token for accessing the registry, thus preventing the 403 Forbidden error.

This should resolve the issue so you can push your container images to Artifact Registry successfully.

Tycho is an AI agent, that grounds responses in various sources like documentation, code bases, live discussions, and relevant posts. Want to chat privately with Tycho?

No comments yet.

Answer by EclipseCollector903 1 month ago

0

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

No comments yet.

Discussion

No comments yet.