Sub topic 16
Troubleshooting common push and pull errors
This chapter assumes you can build an image, run docker login, and push to GHCR or ECR as covered in earlier chapters. It also assumes you know what an image pull secret is in Kubernetes. Most registry failures fall into three groups: the client cannot authenticate, the client is authenticated but not allowed, or the reference points at something that does not exist.
Work out which stage failed
Read the error text before changing anything. The wording tells you which group you are in.
Authentication errors
The message no basic auth credentials means Docker sent no credentials for that host. unauthorized or authentication required means it sent credentials the registry rejected.
Common causes:
- Expired ECR token. The password from
aws ecr get-login-passwordlasts 12 hours. Run the login command again. - Wrong registry host in the login. Logging in to
ghcr.iodoes not help a push to123456789012.dkr.ecr.us-east-1.amazonaws.com. Credentials are stored per host. - Wrong region. ECR hosts are region-specific. A token from
us-east-1does not work against aeu-west-1host. - Wrong GHCR username or token. The token must be a personal access token (classic) with
write:packagesto push orread:packagesto pull.
To see what Docker has stored, look at ~/.docker/config.json. It lists hosts, not secrets, when a credential helper is in use.
Authorization errors
If login succeeds but the push or pull returns denied, the identity is valid but lacks permission.
- GHCR: the token lacks the scope, or the package is private and your account has no access to it. Check the package's access settings on GitHub.
- ECR: the IAM identity needs actions such as
ecr:BatchCheckLayerAvailability,ecr:PutImage,ecr:InitiateLayerUpload,ecr:UploadLayerPart, andecr:CompleteLayerUploadto push. Pulling needsecr:BatchGetImageandecr:GetDownloadUrlForLayer. Every login also needsecr:GetAuthorizationToken. - GitHub Actions: the workflow needs
packages: writeunderpermissions, as in the earlier workflow example.
You can confirm which AWS identity you are using:
aws sts get-caller-identityReference errors
not found, manifest unknown, and repository does not exist usually mean the reference is wrong.
- Uppercase letters. Repository paths must be lowercase.
ghcr.io/MyOrg/appfails;ghcr.io/myorg/appworks. - Missing repository. ECR does not create repositories on push. Create it first with
aws ecr create-repository. - Tag typo or missing tag. Confirm the tag exists, or use the digest.
- Immutable tag. With
IMMUTABLEset on an ECR repository, pushing an existing tag fails. Push a new version tag instead.
Kubernetes pulls
A pod stuck in ErrImagePull or ImagePullBackOff is a pull failure seen from the kubelet. Describe the pod to read the real message:
kubectl describe pod my-appThen check these in order:
- The secret exists in the same namespace as the pod.
- The pod lists it under
imagePullSecrets. - The secret's server matches the image host exactly (
ghcr.iofor GHCR). - The token has not expired or been revoked.
- For ECR with node IAM roles, the node role has the pull permissions listed above.
Quick reference
| Symptom | Likely cause | Fix |
|---|---|---|
| `no basic auth credentials` | Not logged in to that host | Run `docker login` for the host |
| `unauthorized` on ECR after hours | Token expired | Request a new login password |
| `denied` on GHCR push | Missing `write:packages` or package access | Update token scope or package access |
| `name invalid` or `not found` | Uppercase in path | Lowercase the repository path |
| `repository does not exist` on ECR | Repository not created | Create it first |
| `tag invalid` on ECR | Immutable tag already exists | Push a new tag |
Exercise
A pod in namespace prod shows ImagePullBackOff for ghcr.io/acme/api:2.1.0. The secret ghcr-pull exists only in namespace default. What is wrong, and how do you fix it?
Show answer
Image pull secrets are namespaced, and a pod can only use secrets in its own namespace. Create the secret in prod with kubectl create secret docker-registry ghcr-pull -n prod ..., and list it under imagePullSecrets in the pod spec.
Exercise
Your CI job pushed to ECR successfully this morning. Tonight a long-running manual session gets unauthorized on docker push, with the same command. What is the most likely cause, and what do you run?
Show answer
The 12-hour ECR login token has expired. Run aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 123456789012.dkr.ecr.us-east-1.amazonaws.com again, then retry the push.