Docker push - Error - requested access to the resource is denied

Can someone help me with the following problem?

First I logged in to Docker by executing the command:

$ docker login

It includes the registered user and password, but without problems when sending an image to the Docker Hub. When I run the following command:

$ docker push projetofinal2_web

The following error occurs:

The push refers to a repository [docker.io/library/projetofinal2_web]
6e2e1155d419: Preparing 
1cb633a23e71: Preparing 
6b91dd5a05f0: Preparing 
7dc8d752af64: Preparing 
af8b16133eb3: Preparing 
27951393f8e7: Waiting 
f89067d6e30e: Waiting 
5129f19da2c9: Waiting 
34929ec591c4: Waiting 
e02b32b1ff99: Waiting 
f75e64f96dbc: Waiting 
8f7ee6d76fd9: Waiting 
c23711a84ad4: Waiting 
90d1009ce6fe: Waiting 
denied: requested access to the resource is denied

I have verified that the projetofinal2_web image actually exists using the command:

$ docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
projetofinal2_web   latest              c27ee5582377        17 minutes ago      983MB
<none>              <none>              082bd1514477        28 hours ago        918MB
<none>              <none>              148f5843aabb        2 days ago          981MB
<none>              <none>              ac09ab02e2f3        2 days ago          981MB
postgres            latest              f9b577fb1ed6        6 days ago          311MB
python              3.6.7               1ec4d11819ad        2 weeks ago         918MB

Project in GitHub: https://github.com/gabrieldeoliveiraestevam/projeto?files=1

1 Like

Make sure your logging into the right area… I had this using GitLab’s CI, each docker login passed but the push failed.

I changed the process to do this, and it solved it for me…

docker login -u "myusername" -p "mypassword" docker.io
docker push myusername/myimage:0.0.1

I also added myusername as a contributer to by docker hub repo. I’m not sure whether or not this final step is needed as I was trying everything at the time to get it to work.

9 Likes

Then I must execute the command below?

$ docker login -u "myusername" -p "mypassword" docker.io
$ docker push projetofinal2_web 

I did not understand why in your case you informed myusername / myimage: 0.0.1. What does 0.0.1 mean?

Before doing PUSH should I create the repository in the Docker Hub?

Thank you!

1 Like

The main point was telling docker login which repository to login to. Then you need to push to your repository, which is usually username/image.

In my case I had an image tagged as version 0.0.1, so that was what I was pushing.

Off the top of my head, I can’t remember whether pushing no tag version automatically tags it latest, as I’ve always versioned with numbers.

What you’ve written may work, or you may have to include your username as part of the push…

3 Likes

Got it,

The timing is not as powerful as the command.

Previously, you did not need to create a repository in the Docker Hub with the name projetofinal2_web ?

As below:

1 Like

So in that scenario I’d probably have:

docker build -t gabrieldeoliveiraest/projetofinal2_web:latest -f Dockerfile .
docker login -u "gabrieldeoliveiraest" -p "password" docker.io
docker push gabrieldeoliveiraest/projetofinal2_web:latest

I.e, build and tag the image, login to docker, then push the created image to docker.io.

2 Likes

Hi gabriel, you should be create a [tag] from your docker image and later push this to your docker hub, here the example:

docker tag projetofinal2_web gabrieldeoliveiraest/projetofinal2_web:version1
docker push gabrieldeoliveiraest/projetofinal2_web:version1
11 Likes

Hi there,
delete/rename the config.json file from ~/.docker/ location and then login again:

docker login --username=your_username --email=name@email.com docker.io

Cheers!

1 Like

it was the solution for my case :smiling_face:

1 Like

Make sure you have tagged your image in this format:
{{username}}/{{imagename}}:{{version}}
And push with

docker push {{username}}/{{imagename}}:{{version}}

770206925619: Pushed 
19bdf30c3ec9: Pushed 
14c57xc270af: Pushed 
644c37dc1716: Pushed 
0d93f313b408: Pushed 
bf67ef0447f3: Pushed 
9c97a15abfed: Pushed 
a8063f4b5a7d: Pushed 
8c487s756d71: Pushed 
05c02se771c8: Pushed 
e9313s51f46d: Pushed 
46601qcd4114: Pushed 
31b0ee48310d: Pushed 

I was trying with {{imagename}}:{{version}} and did not work.

15 Likes

Root cause :- You are pushing the image from docker,io/library which is a local repo.

In order to push your images to hub you have to create a TAG using your local image
in your case it woul be

#docker tag projetofinal2_web gabrieldeoliveiraest/projetofinal2_web:version1
#docker push gabrieldeoliveiraest/projetofinal2_web:version1

4 Likes

change image name without ‘/’, try with simple name

1 Like

I actually tried pushing to the hub too and I got this error too.
username: alhajidot
repository name: spark
local image name: alhajidot:spark

now I want to push this image to dockerhub.
These are the commands I used.

username: alhajidot

password: *******

and then

docker tag alhajidot:spark spark:newspark
docker push alhajidot:spark

This has refused to work. How can I get it to work?

Perfect. It solved my problem, thanks

1 Like

Really worked, i was missing the user name

Thank you so much. it workes for me.

This also worked for me. Thanks!

This is the solution for my error. Thanks :slight_smile:

Make sure {{username}} is your Docker Hub username…

If you’re using private repositories and have gone over the limit, try reducing the # of repository to within limits, then deleting the repository you get this err msg on and re-push.

I’ve had this problem occur when creating a private repository that takes the # of repositories outside of the limits (e.g. 51 out of 50 private repositories). The err msg continues even after reducing # of repositories and the fix is to delete the repository created while account had gone over limit and re-push the image.