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.

(Note: - If you are in a real hurry then you can directly jump to Step 4 and Step 5 but I would highly recommend you to go through this blog post to fix the issue properly)

Here are the steps which you need to follow for troubleshooting -

Table of Content

  1. Why this error happened in the first place?
  2. Step 1 - Let's do the docker logout first
  3. Step 2 - Build and tag docker image correctly
  4. Step 3 - Docker Login before pushing the docker image to docker hub
  5. 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 docker command.

Speaking in layman's term here are the following possible scenarios -

  1. Either you as a docker user do not have access to the docker hub repository
  2. 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 -

1docker logout 

And this is how it should look once your successfully run the above command -

docker logout for fixing requested access to the resource is denied error



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.

docker hub repository name

I am going to run the following command for building and tagging my docker image -

  1. Docker build and tag
1docker build -t jhooq-docker-demo .
  1. 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 docker login

1docker login 

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

docker hub login for fixing requested access to the resource is denied error



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

docker hub login for fixing requested access to the resource is denied error

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

  1. StackOverflow - denied: requested access to the resource is denied : docker
  2. Docker Forum - Docker push - Error - requested access to the resource is denied

Posts in this Series