docker pull or push to ghcr.io fails with 'denied'
Error response from daemon: deniedShort answer
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. Private is the default visibility for a new package, so an anonymous pull of it is denied.
Fix it fast
1Find out which cause you have
Log in to the registry explicitly, then repeat the pull. If it works, the problem was authentication; if not, continue with the scope and access causes.
echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdin2Match what you see, then jump to its fix
- 1
docker pull ghcr.io/NAMESPACE/IMAGE_NAME is denied on a machine or job that never ran docker login.Docker is not logged in to ghcr.io (and the package is private)Fix - 2
Login succeeds, but the pull or push is still denied.The personal access token has no package scopeFix - 3
docker push from a workflow is denied, and the workflow limits permissions.The workflow's GITHUB_TOKEN has no packages permissionFix - 4
The package already exists (for example it was first pushed by hand) and the workflow's push or pull is denied.The repository has no Actions access to an existing packageFix
- 1
What does the error look like?
Error response from daemon: denied
Cause 1 of 4
Docker is not logged in to ghcr.io (and the package is private)
1Check
A newly published package is private by default, and you need an access token to pull private, internal or public packages through Docker's login.
docker pull ghcr.io/NAMESPACE/IMAGE_NAME2Fix
Store a classic personal access token in an environment variable and log in with it, or in a workflow use docker/login-action with the GITHUB_TOKEN.
export CR_PAT=YOUR_TOKEN
echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdin3Verify
The pull succeeds.
docker pull ghcr.io/NAMESPACE/IMAGE_NAMEConfirmed by docs.github.com
Cause 2 of 4
The personal access token has no package scope
1Check
A classic token needs read:packages to download images and write:packages to upload them.
# GitHub, Settings, Developer settings, Personal access tokens: read the scopes2Fix
Create a classic token with the scope you need. The write:packages scope also selects repo by default in the web form; the docs give a URL that preselects only the package scope.
# https://github.com/settings/tokens/new?scopes=write:packages3Verify
Log in with the new token and repeat the command.
echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdinConfirmed by docs.github.com
Cause 3 of 4
The workflow's GITHUB_TOKEN has no packages permission
1Check
For registries with repository-scoped permissions, the docs recommend read for contents and write for packages.
grep -n -A4 "permissions:" .github/workflows/*.yml2Fix
Set the permissions on the job and log in with the token.
permissions:
contents: read
packages: write
steps:
- uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}3Verify
Re-run the job; the push step passes.
gh run watch --exit-statusConfirmed by docs.github.com
Cause 4 of 4
The repository has no Actions access to an existing package
1Check
A workflow can only use a package once its repository is added in the package settings under Manage Actions access.
# Package page, Package settings, Manage Actions access2Fix
Click Add repository, choose the workflow's repository, and set a role that allows what the workflow does.
# Package settings > Manage Actions access > Add repository3Verify
Re-run the failed job.
gh run watch --exit-statusConfirmed by docs.github.com
How do I stop it coming back?
- Use the GITHUB_TOKEN with an explicit packages permission in workflows instead of a long-lived personal token.
- Pull by name for tags and by digest when you need a fixed version.
- Decide package visibility on purpose after the first publish, since the default is private.
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
Docker push to Artifact Registry fails from GitHub Actions with a permission error
Permission 'artifactregistry.repositories.uploadArtifacts' denied on resource
The identity your workflow authenticates as lacks the permission artifactregistry.repositories.uploadArtifacts on the target repository.
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 fixServers
Angular routes return 404 from nginx when you refresh or open a link
The home page loads, but refreshing /some/route shows an nginx 404
Angular routes like /users/42 are not files, so nginx looks for them on disk and returns 404.
3 causes, each with a fix