Sub topic 11
Fixing common push errors
This chapter assumes you can build an image, log in with docker login, and run docker tag and docker push. Most push failures come from three things: the image name, the login state, or the token's permissions. If you check them in that order, you will find most causes quickly.
Read the first line of output
Before it reports an error, docker push prints the repository it is pushing to:
The push refers to repository [docker.io/library/myapp]
denied: requested access to the resource is deniedThe bracketed name is the repository Docker resolved from your image name. A name with no namespace, such as myapp, resolves to library/myapp. That is the namespace for Docker's official images, and you cannot write to it. Check this line first. It tells you whether Docker is aiming at your repository.
Common errors and fixes
| Message | Likely cause | Fix |
|---|---|---|
| `denied: requested access to the resource is denied` | Missing namespace, wrong namespace, not logged in, or a token without write access | Check the name, then the login, then the token scope |
| `An image does not exist locally with the tag: ...` | The name you pushed was never created with `docker tag` or `docker build -t` | Run `docker images` and push a name that is listed |
| `unauthorized: incorrect username or password` | Wrong credentials, or a password used where a token is required | Log in again with a valid personal access token |
| `invalid reference format` | Uppercase letters or illegal characters in the repository name | Use lowercase letters, digits, and `-`, `_`, `.` |
| `Client.Timeout exceeded` or `connection refused` | Network, proxy, or firewall problem | Check connectivity and the Docker daemon's proxy settings |
A decision path
The denied error in practice
The most common failure is pushing the local name directly:
docker push myapp:1.0Docker reads this as library/myapp:1.0 and refuses. Add a second name that includes your namespace, then push that name:
docker tag myapp:1.0 YOUR_USERNAME/myapp:1.0
docker push YOUR_USERNAME/myapp:1.0If the name is already correct, check that the namespace matches your account exactly. Namespaces are lowercase, so a typo in a username or organization name sends the push to a repository you cannot write to.
Login problems
A successful docker login stores credentials for the registry. Confirm that an entry exists:
grep -A3 '"auths"' ~/.docker/config.jsonAn entry for https://index.docker.io/v1/ means credentials are stored. Your system may keep the secret in a credential helper instead. In that case the file shows a credsStore value, and the auths entry may be empty.
Two situations cause repeated unauthorized errors:
- Two-factor authentication is on, and you typed your account password. Use a personal access token instead.
- The token was revoked or expired. Create a new one in your Docker Hub account settings and run
docker loginagain.
Repository and network issues
If the name and the login are both correct, look at these causes:
- The repository belongs to an organization, and your account is not on a team with write permission.
- You hit a plan limit on private repositories, so Docker Hub could not create a new one on push.
- A corporate proxy or firewall blocks
registry-1.docker.io. A timeout, notdenied, is the sign of this case.
You can test the network separately from your image:
docker pull alpine:3.20If this pull also hangs, the problem is connectivity, not your push.
Narrowing it down
Change one thing at a time, and push again after each change. Start with docker images to confirm the exact local name. Then confirm the login. Last, confirm the token scope. If you change the name, the login, and the token together, you will not know which change fixed the failure.
Exercise
You run docker push myapp:1.0 after a successful docker login. Docker prints The push refers to repository [docker.io/library/myapp] and then denied: requested access to the resource is denied. What went wrong, and what two commands fix it?
Show answer
The image name has no namespace, so Docker resolved it to library/myapp, which you cannot write to. Run docker tag myapp:1.0 YOUR_USERNAME/myapp:1.0, then docker push YOUR_USERNAME/myapp:1.0.