Docker push to Artifact Registry fails from GitHub Actions with a permission error
Permission 'artifactregistry.repositories.uploadArtifacts' denied on resourceShort answer
The identity your workflow authenticates as lacks the permission artifactregistry.repositories.uploadArtifacts on the target repository. Grant that identity the Artifact Registry Writer role on the repository, make sure Docker is set up for the repository's region host, and check that the image path names a repository that exists.
Fix it fast
1Find out which cause you have
Read the resource path in the error, then list which identities hold a role on that repository.
gcloud artifacts repositories get-iam-policy REPOSITORY --location=LOCATION --project=PROJECT_ID2Match what you see, then jump to its fix
- 1
The policy from the first step has no entry for the service account or principal your workflow usesThe workflow identity has no Writer role on the repositoryFix - 2
Writer exists on the repository, but for another service account, such as the one used for deploysThe role was granted to a different account than the one pushingFix - 3
The push goes to LOCATION-docker.pkg.dev, but no credential helper entry exists for that exact hostDocker is not set up for the repository's region hostFix - 4
The path in the error has a repository or location that is not in the repository listThe image path names a repository that does not existFix
- 1
What does the error look like?
Permission 'artifactregistry.repositories.uploadArtifacts' denied on resource
Cause 1 of 4
The workflow identity has no Writer role on the repository
1Check
Compare the email in your auth step (the service account) with the members in the policy. Reading images is not enough: pushing needs a role that contains uploadArtifacts, and Writer is the standard choice.
gcloud artifacts repositories get-iam-policy REPOSITORY --location=LOCATION --project=PROJECT_ID2Fix
Grant Artifact Registry Writer to that identity on the repository, or on the project if it should apply to every repository.
gcloud artifacts repositories add-iam-policy-binding REPOSITORY \
--location=LOCATION \
--member=serviceAccount:SA_NAME@PROJECT_ID.iam.gserviceaccount.com \
--role=roles/artifactregistry.writer3Verify
Re-run the failed workflow job. The push step should now upload the image.
docker push LOCATION-docker.pkg.dev/PROJECT_ID/REPOSITORY/IMAGE:TAGConfirmed by docs.cloud.google.com
Cause 2 of 4
The role was granted to a different account than the one pushing
1Check
Roles that contain uploadArtifacts include Writer, Repository Administrator and Create-on-Push Writer. Describe the role to confirm its permissions.
gcloud iam roles describe roles/artifactregistry.writer2Fix
Bind the role to the exact email used in the workflow's auth step, not to a similarly named account.
gcloud artifacts repositories add-iam-policy-binding REPOSITORY \
--location=LOCATION \
--member=serviceAccount:SA_NAME@PROJECT_ID.iam.gserviceaccount.com \
--role=roles/artifactregistry.writer3Verify
Run the workflow again and confirm the push step passes.
gcloud artifacts repositories get-iam-policy REPOSITORY --location=LOCATION --project=PROJECT_IDConfirmed by docs.cloud.google.com
Cause 3 of 4
Docker is not set up for the repository's region host
1Check
Authentication works per regional host. Look for the host in the credHelpers section of the Docker config on the runner.
cat ~/.docker/config.json2Fix
Run the credential helper setup for the same host as the image path, after the auth step and before the push.
gcloud auth configure-docker LOCATION-docker.pkg.dev3Verify
The host now appears in credHelpers, and the push step authenticates.
cat ~/.docker/config.jsonConfirmed by docs.cloud.google.com
Cause 4 of 4
The image path names a repository that does not exist
1Check
The image path format is LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY/IMAGE. List the repositories and compare each part.
gcloud artifacts repositories list --project=PROJECT_ID2Fix
Correct the path in the workflow, or create the Docker repository first if it is missing.
gcloud artifacts repositories create REPOSITORY --repository-format=docker \
--location=LOCATION --project=PROJECT_ID3Verify
Repository appears in the list; then push again.
gcloud artifacts repositories list --project=PROJECT_IDConfirmed by docs.cloud.google.com
How do I stop it coming back?
- Grant Writer on the single repository, not on the whole project.
- Keep the registry host, project and repository in one workflow env variable so the path is spelled once.
- Run gcloud auth configure-docker in the workflow for the exact region you push to.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
GitHub Actions cannot get a Google Cloud token through Workload Identity Federation
No access token or invalid expiration in response
The auth step trades a GitHub OIDC token for a Google token, then impersonates a service account.
3 causes, each with a fixServers
docker pull or push to ghcr.io fails with 'denied'
Error response from daemon: denied
ghcr.io refuses a pull or push when Docker is not logged in, when the token lacks the package scope, or when the workflow's GITHUB_TOKEN has no packages permission or no access to that package.
4 causes, each with a fixServers
git says it could not read Username for https://github.com in a build or CI job
fatal: could not read Username for 'https://github.com': No such device or address
Git asked for HTTPS credentials and there was no terminal to ask on, so it gave up.
3 causes, each with a fixServers
A GitHub Actions workflow builds the Docker image but cannot push it
The push step fails right after the login step
Four things stop a push from GitHub Actions: build-push-action does not push unless push is true, the Docker Hub login used a password instead of an access token, the workflow token lacks packages write for ghcr.io, or the run comes from a fork, where the token is read-only.
4 causes, each with a fixServers
apk cannot find py-pip in an Alpine Docker image
py-pip (no such package):
On current Alpine releases there is no package called py-pip.
2 causes, each with a fixServers
ng serve runs in the container but localhost:4200 does not open
The browser cannot open localhost:4200 although ng serve is running in the container
ng serve listens on localhost by default, which inside a container is the container itself.
3 causes, each with a fix