docker tutorials

Docker: denied: requested access to the resource is denied

This tutorial guides you how to resolve error docker denied: requested access to the resource is denied while trying to push docker image to docker hub or index. Let’s say you have successfully created docker image and trying to push this image to docker hub and resulted with following error.

$ docker push ubuntu/ubuntu_sshd_example
The push refers to repository [docker.io/ubuntu/ubuntu_sshd_example]
3d1065fca287: Preparing
787f7da4f1cf: Preparing
16542a8fc3be: Preparing
6597da2e2e52: Preparing
977183d4e999: Preparing
c8be1b8f4d60: Waiting
denied: requested access to the resource is denied

Solution

It’s recommended that before you push any docker image to docker.io, first remember to logout, then login again as shown below.

$ docker logout
Removing login credentials for https://index.docker.io/v1/

$ docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: <your username>
Password: <password>
WARNING! Your password will be stored unencrypted in /home/nithip2016/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

Then check whether you are using namespace of the Docker Hub or Docker Hub account name as username in the tag applied to the Docker image while building docker image.

Usually, the convention that need to be followed when you tag the docker image before pushing is as follows.

<YOUR_DOCKER_HUB_NAME>/<NEW_IMAGE_NAME> OR <USER_NAME>/<NEW_IMAGE_NAME>

Let’s say your Docker Hub name is “sneppets” and new image name is ubuntu_sshd_example, then you should tag/name the docker image using the above convention and in case if you wanted to rename you could re-commit if required using docker hub name as shown below.

$ docker commit <container-id> <your_docker_hub_name>/ubuntu_sshd_example

For Example,

$ docker commit 8ec4dfc8194e sneppets/ubuntu_sshd_example

Then you should be able to push docker image to docker index using the following command successfully.

$ docker push  sneppets/ubuntu_sshd_example
The push refers to repository [docker.io/sneppets/ubuntu_sshd_example]
3d1065fca287: Pushed
787f7da4f1cf: Pushing [==================================================>]  149.2MB
16542a8fc3be: Pushed
6597da2e2e52: Pushed
977183d4e999: Pushed
c8be1b8f4d60: Pushing [==================================================>]  65.58MB
$ docker push  sneppets/ubuntu_sshd_example
The push refers to repository [docker.io/sneppets/ubuntu_sshd_example]
3d1065fca287: Pushed
787f7da4f1cf: Pushed
16542a8fc3be: Pushed
6597da2e2e52: Pushed
977183d4e999: Pushed
c8be1b8f4d60: Pushed
latest: digest: sha256:06a26756c8fdd64dc39cc2eea0ffdf667a1934ae09be04c08a9db0769fd51232 size: 1572

Check whether image is pushed in to the hub by login to docker.com using your docker id and password.

You can also use the following command docker pull  image, run and test.

$ docker pull sneppets/ubuntu_sshd_example
Using default tag: latest
latest: Pulling from sneppets/ubuntu_sshd_example
5bed26d33875: Already exists
f11b29a9c730: Already exists
930bda195c84: Already exists
78bf9a5ad49e: Already exists
09d1fc91f1f6: Pull complete
8ec497c8194e: Pull complete
Digest: sha256:06a26756c8fdd64dc39cc2eea0ffdf667a1934ae09be04c08a9db0769fd51232
Status: Downloaded newer image for sneppets/ubuntu_sshd_example:latest
docker.io/sneppets/ubuntu_sshd_example:latest

$ docker images
REPOSITORY                         TAG                 IMAGE ID            CREATED             SIZE
sneppets/ubuntu_sshd_example   latest              0a21dffc24ce        24 minutes ago      208MB

Also Read

References

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments