How to fix requested access to the resource is denied?
I faced the error requested access to the resource is denied while I was trying to push my docker image of spring boot application to Docker Hub but unfortunately when I issued the
docker push command I immediately got the error.
In this article, we will look at How to fix requested access to the resource is denied error and also the recommended ways to use the docker push command so that you can avoid this type of error in the future.
Here are the steps which you need to follow for troubleshooting -
Table of Content
- Why this error happened in the first place?
- Step 1 - Let's do the docker logout first
- Step 2 - Build and tag docker image correctly
- Step 3 - Docker Login before pushing the docker image to docker hub
- Step 4 - Do the docker push
1. Why did this error happen in the first place?
Let's first try to understand the root cause of this error. As the error says requested access to the resource is denied error which means you as a docker user do not have the correct rights/permission to run the
docker push or any other
Speaking in layman's term here are the following possible scenarios -
- Either you as a docker user do not have access to the docker hub repository
- Or you are not using the docker hub credentials correctly.
2. Step 1 - Let's do the docker logout first
Before we perform any troubleshooting command I would highly recommend you to run the
docker logout command from your terminal.
The benefit of the
docker logout would be - "If by any chance your previous docker session is connected with wrong docker hub repository then after running the
docker logout command you will be logged out and your session will be terminated."
Here is the command for
docker logout -
And this is how it should look once your successfully run the above command -
3. Step 2 - Build and tag docker image correctly
The second most important step for troubleshooting this error would be to build and tag your docker image correctly according to the name of your docker hub repository.
As you can see in the below image my docker hub repository name is -
rahulwagh17/jhooq-docker-demo, so I am going to build and tag my docker image accordingly.
I am going to run the following command for building and tagging my docker image -
- Docker build and tag
1docker build -t jhooq-docker-demo .
- Docker tag as per the docker hub repository name
1docker tag jhooq-docker-demo rahulwagh17/jhooq-docker-demo:jhooq-docker-demo
Alright, now we have to build a docker image and also tagged it as per our docker hub repository name.
4. Step 3 - Docker Login before pushing the docker image to docker hub
Now in the previous step 3 we have built and tagged the docker image.
Now we need to do the
docker login from the command line (remember we have already logged out from any exiting docker session in the step 1)
Here is the command for
Once you issue the docker login command it will ask for your docker hub username and password.
1Login with your Docker ID 2Username : rahulwagh17 3Password:
Supply your username and password. After the successful authentication, you will see a message Login Succeeded
5. Step 4 - Do the docker push
Now, this is going to be your final step where you are going to perform the docker push. Here is an example command for pushing your docker image to the docker hub but you can alter the command as per your need.
1 docker push rahulwagh17/jhooq-docker-demo:jhooq-docker-demo
And here are the successful logs
Voila your error is gone.
I hope this troubleshooting guide will help you to fix your issue requested access to the resource is denied.
Here are some references
Posts in this Series
- How to push Docker Images to AWS ECR(Elastic Container registry)?
- How to Copy Docker images from one host to another host?
- What is persistent storage in docker and how to manage it
- Docker Installation on MacOS, Linux and Windows
- Docker - ADD, Update, Export Environment variable
- How to fix-Docker docker failed to compute cache key not found
- How to fix docker driver failed programming external connectivity on endpoint webserver?
- How to fix docker error executable file not found in $PATH?
- How to expose port on live containers?
- How to expose multiple ports with Docker?
- How to restart single docker container within multiple docker container?
- How to edit file within Docker container or edit a file after I shell into a Docker container?
- How to fix Error starting docker service Unit not found?
- How to remove old, unused images of Docker?
- How to fix docker error invalid reference format error?
- How to fix requested access to the resource is denied?
- How to fix Docker error cannot delete docker container conflict unable to remove repository reference?
- How to fix docker error no space left on device?
- How to connect localhost from docker container?
- Docker COPY vs Docker ADD?
- 6 Ways to fix - Got permission denied while trying to connect to the Docker daemon socket?
- 6 Ways to fix – Docker COPY failed: stat no source files were specified