The 'requested access to the resource is denied' error occurs when pushing a Docker image to a registry. This typically happens because the image is not tagged with your Docker Hub username, you are not logged in, or you are trying to push to a repository you do not own.
This error message appears when Docker attempts to push an image to a container registry (like Docker Hub) but the operation is rejected by the registry. The registry denies access for several reasons related to authentication or authorization. The most common cause is that the image is not properly tagged with your Docker Hub namespace (username). Docker Hub requires images to be named in the format `username/imagename:tag`. If you try to push an image without your username in the tag, Docker Hub does not know which account should own the image and denies the request. Additionally, this error occurs if: 1. **You are not logged in** - The Docker client has not authenticated with the registry 2. **Session expired** - Your login credentials have become stale or corrupted 3. **Wrong namespace** - You are trying to push to a repository owned by another user or organization 4. **Private repository limits** - You have exceeded your free tier limit for private repositories
The most common fix is to tag your image with your Docker Hub username as the namespace. Docker Hub requires images to follow the format username/image:tag.
# Check your current image name
docker images
# Tag the image with your username
docker tag myimage:latest YOUR_DOCKERHUB_USERNAME/myimage:latest
# Now push the correctly tagged image
docker push YOUR_DOCKERHUB_USERNAME/myimage:latestReplace YOUR_DOCKERHUB_USERNAME with your actual Docker Hub username. You can find your username by logging into hub.docker.com.
Ensure you are authenticated with Docker Hub before pushing:
# Log in to Docker Hub
docker login
# Enter your username and password when prompted
# Or use stdin for CI/CD environments
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdinAfter logging in, you should see "Login Succeeded". Your credentials are stored in ~/.docker/config.json.
If you were already logged in but still get the error, your credentials may be stale or corrupted. Force a fresh login:
# Log out first
docker logout
# Log back in
docker loginThis clears any cached credentials and forces Docker to re-authenticate with the registry.
Docker Hub requires email verification before you can push images. If you have not confirmed your email:
1. Go to [hub.docker.com](https://hub.docker.com) and log in
2. Check your account settings for email verification status
3. If unverified, request a new verification email
4. Click the verification link in the email
5. Try pushing again after verification
To avoid retagging, build your image with the correct name from the beginning:
# Build with your username in the tag
docker build -t YOUR_DOCKERHUB_USERNAME/myimage:latest .
# Push directly
docker push YOUR_DOCKERHUB_USERNAME/myimage:latestFor CI/CD pipelines, use environment variables:
docker build -t $DOCKER_USERNAME/myimage:$TAG .
docker push $DOCKER_USERNAME/myimage:$TAGIf the above steps do not work, try a complete credential reset:
# Log out from all registries
docker logout
# Backup and remove the Docker config file
mv ~/.docker/config.json ~/.docker/config.json.backup
# Restart Docker daemon (Linux)
sudo systemctl restart docker
# Or restart Docker Desktop (macOS/Windows)
# Use the Docker Desktop menu to restart
# Log in fresh
docker loginThis clears all stored credentials and forces a complete re-authentication.
### Private Registry Authentication
For private registries, you must include the registry URL in both the login and tag commands:
# Log in to private registry
docker login registry.example.com
# Tag with registry URL
docker tag myimage:latest registry.example.com/myimage:latest
# Push to private registry
docker push registry.example.com/myimage:latestDo NOT include the registry URL when logging into Docker Hub - use just docker login without a URL parameter.
### Docker Hub Private Repository Limits
Docker Hub free accounts have a limit on private repositories. If you exceed this limit:
- New pushes to private repositories will fail with "access denied"
- The repository may be created but in a blocked state
- Solution: Delete unused private repos, or upgrade your Docker Hub plan
Check your repository count at hub.docker.com under your account settings.
### Sudo and Credential Scope
If you use sudo for some Docker commands, be aware that credentials are stored per-user:
# Credentials stored in ~/.docker/config.json
docker login
docker push username/image
# Credentials stored in /root/.docker/config.json
sudo docker login
sudo docker push username/imageBe consistent with sudo usage. If you use sudo docker push, you must also use sudo docker login.
### Organization Repositories
To push to an organization repository, your account must:
1. Be a member of the organization
2. Have push access to the specific repository
Tag the image with the organization name:
docker tag myimage:latest myorganization/myimage:latest
docker push myorganization/myimage:latest### GitHub Container Registry (GHCR)
For GitHub Container Registry, use a Personal Access Token (PAT) with the write:packages scope:
echo $GITHUB_PAT | docker login ghcr.io -u USERNAME --password-stdin
docker tag myimage:latest ghcr.io/USERNAME/myimage:latest
docker push ghcr.io/USERNAME/myimage:latest### Amazon ECR
For Amazon ECR, authenticate using the AWS CLI:
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 123456789012.dkr.ecr.us-east-1.amazonaws.comdockerfile parse error line 5: unknown instruction: RRUN
How to fix 'unknown instruction' Dockerfile parse error in Docker
Error response from daemon: manifest for nginx:nonexistent not found: manifest unknown: manifest unknown
How to fix 'manifest for image:tag not found' in Docker
Error response from daemon: invalid reference format: repository name must be lowercase
How to fix 'repository name must be lowercase' in Docker
Error response from daemon: No such image
How to fix 'No such image' in Docker
Error response from daemon: Container is not running
How to fix 'Container is not running' when using docker exec