762

I am following this link to create my first docker Image and it went successfully and now I am trying to push this Image into my docker repository from this link. But whenever I am trying to push this Image into repository, I got this type of error.

denied: requested access to the resource is denied

Note: I have successfully login into docker

4

64 Answers 64

1170

You may need to switch your docker repo to private before docker push.

Thanks to the answer provided by Dean Wu and this comment by ses, before pushing, remember to log out, then log in from the command line to your docker hub account

# you may need log out first `docker logout` ref. https://stackoverflow.com/a/53835882/248616
docker login

According to the docs:

You need to include the namespace for Docker Hub to associate it with your account.
The namespace is the same as your Docker Hub account name.
You need to rename the image to YOUR_DOCKERHUB_NAME/docker-whale.

So, this means you have to tag your image before pushing:

docker tag firstimage YOUR_DOCKERHUB_NAME/firstimage

and then you should be able to push it.

docker push YOUR_DOCKERHUB_NAME/firstimage
21
  • 67
    Not for me. I've tried all combinations of [host]/[namespace]/[repo] and still the same error (meaning, i have organizations and my account as the namespace). Even tried docker login .... I can't push :-|
    – nicerobot
    Feb 2, 2017 at 23:38
  • 1
    hii i follow your command got Error ---Error response from daemon: No such image: ubuntu-nodejs:latest
    – Yash
    Apr 12, 2017 at 11:04
  • 62
    This answer should not have been marked as accepted! The solution provided clearly does not work as others have indicated.
    – SamDevx
    Apr 30, 2017 at 3:11
  • 8
    I had the same issue and it turned out that I was not logged in properly. "docker login" behaves awkwardly, it showed "login succeeded" even when I entered wrong password. So to login appropriately, I used "docker login <url> --username=<username>". Post this, "docker push" worked as expected. May 16, 2017 at 14:07
  • 3
    This answer is not complete and didn't work for me. Venu S provided a complete answer which solved this problem for me.
    – rm.rf.etc
    Aug 24, 2017 at 21:26
259

I had the same issue, but accepted answer given here did not work for me. I tried few steps and was able to get around to push it finally.

Here are the steps worked for me:

  1. Login to the docker.

    docker login -u sirimalla

  2. Tag your image build

my image name here is mylocalimage and by default it has tag latest
and my username is sirimalla as registered with docker cloud, and I created a public repository named dockerhub

so my personal repository becomes now sirimalla/dockerhub and I want to push my image with tag myfirstimagepush

I tagged as below :

docker tag mylocalimage:latest sirimalla/dockerhub:myfirstimagepush
  1. Pushed the image to my personal docker repository as below

    docker push sirimalla/dockerhub:myfirstimagepush

And it successfully pushed to my personal docker repo.

10
  • 9
    This answer solved my problem. This should be the accepted answer. The other answer is not complete and did not work for me. For example, the other answer makes no mention of docker login. Until coming to this thread, I didn't know about docker login.
    – rm.rf.etc
    Aug 24, 2017 at 21:24
  • in general you should be using sudo prefixing all your commands ref projectatomic.io/blog/2015/08/…
    – wmitchell
    Nov 10, 2017 at 1:28
  • Caveat with sudo - see my answer
    – rhoerbe
    Aug 27, 2018 at 9:14
  • 5
    This was the puppy. Jul 16, 2019 at 15:52
  • 5
    Yup, this answer only solved my problem. Please refer this whoever want to solve this issue.
    – Maha Lak
    Sep 26, 2019 at 9:32
241

I got the same issue while taking the docker beginner Course. I solved the issue by doing adocker login before the docker push call.

4
  • 17
    FWIW, I was getting error getting credentials on docker login. sudo docker login worked for me. This allowed me to push my private repo. Mar 14, 2017 at 17:34
  • 2
    Apparently the Docker webinar is outdated. May 30, 2017 at 18:13
  • Caveat with sudo - see my answer
    – rhoerbe
    Aug 27, 2018 at 9:15
  • I did docker login AND tagged my local image with docker tag ubuntu franva/ubuntu, then I ran docker push franva/ubuntu
    – Franva
    May 22, 2021 at 4:56
67

Use Below commands:

$ docker login
<enter user name and password for Docker Hub Repository>

$ docker tag first-image {docker-hub-username}/{default-repo-folder-name}:first-image

$ docker push {docker-hub-username}/{default-repo-folder-name}:first-image

e.g. I have public repository like manjeet86/docker-repo so commands would be:

$ docker tag first-image manjeet86/docker-repo:first-image

$ docker push manjeet86/docker-repo:first-image

Just see : instead of / that was the trick. It works for me. I do not know if it lets you tag with / as well in place of : but that may be for some other purpose.

https://docs.docker.com/engine/reference/commandline/tag/#examples

3
55

Important also to note is that when you tag your image, you tag it using the Namespace and then your repository / mydevrepo. This confused me when following the Docker docs. After that I used:

docker login

And then I pushed my Image using the 'tagged name'.

docker push {namespace}/mydevrepo
1
  • 2
    In other words do something like {namespace}/wordpress-cli-ansible and not {namespace}/wordpress-helm/wordpress-cli-ansible. That's one issue I was having which was preventing me from pushing.
    – vhs
    Dec 9, 2020 at 9:32
25

Here is a work-around as of January, 2018:

  1. Go to hub.docker.com and change your repository to private

  2. In your shell run:

    docker images

    REPOSITORY TAG IMAGE ID CREATED SIZE verse_gapminder_gsl latest 023ab91c6291 3 minutes ago 1.975 GB verse_gapminder latest bb38976d03cf 13 minutes ago 1.955 GB rocker/verse latest 0168d115f220 3 days ago 1.954 GB

    docker tag bb38976d03cf dockhubusername/verse_gapminder:mytag

    docker login docker.io

    docker push dockhubusername/verse_gapminder:mytag

  3. Go back to docker hub and change the repository back to public.

2
  • #without the specific login command above, kept getting access error when pushing, even though i had logged in via command line Oct 15, 2020 at 3:47
  • first login then use these commands it will work definitely $ docker image tag nginx my-user-name/nginx $ docker image push my-user-name/nginx:latest
    – subhashis
    Oct 14, 2021 at 7:06
21

I was facing the same issue, I was giving my image name as something/image-name but instead I tried with <docker-hub-username>/image-name and it worked like a charm.

Step 1

docker login --username=jp9573

Step 2

docker push jp9573/todo

Earlier I was giving jaypatel/todo, I just changed it to the username/image pattern. In this way, I don't have to tag the image or anything. I think it's a good way for a newcomer.

1
  • Tried all possible things and this simple username worked like a charm May 24, 2021 at 14:15
20

I was with this issue too, I tested the solutions in here present but to no avail, I was properly logged in, at least according to the output of docker login but still I could not push the image. What finally worked was simply to do:

docker logout

And then docker login again, it was that trivial. I'm not sure what happened but forcing the re-login worked.

2
  • 1
    Yeah with logout, it comes back working for me. Thank you!
    – Nam G VU
    Mar 4, 2020 at 14:38
  • Nope, logout does not work for me. Man, Docker sucks really bad, I can't believe they can't manage to display more of a useful error message, this error message says absolutely nothing, this makes the problem impossible to solve. Debugging on? No difference. Docker is on my list of technologies that need replacing if it can't reliably work. Jun 5, 2021 at 8:37
20

It worked for me when I used my docker hub name while tagging image. (Here, xyz is a docker hub name)

# Login to docker hub account 
docker login 

# tag image 
docker tag nginx xyz/nginx

# push image
docker push xyz/nginx
1
  • Worked for me. I didn't tag the image earlier. I thought It does tag automatically since I'm logged in. Dec 24, 2021 at 9:38
18

I had the same issue today. The only thing that worked for me was to explicitly login to "docker.io":

docker login docker.io

I tried various other names, and the login would appear to work, but it would later result in the following error.

requested access to the resource is denied

4
  • 3
    This is also what resolved the issue for me. I tried docker login with no success, but the explicit docker.io on the end did the trick.
    – jooks
    Jan 15, 2018 at 18:31
  • This was it for me
    – Glitcher
    May 8, 2018 at 19:52
  • explicit login to docker.io did not work for me. Login worked in the past, stopped working now.
    – rhoerbe
    Jul 17, 2018 at 8:13
  • This was the solution for me. But I added double quote. Like this: - docker login -u "username" -p "password" docker.io Sep 3, 2020 at 16:04
14

Docker also has a limit on the number of private repositories you can have. If you're creating a private repository by pushing from your local machine, it will create the repository but nothing further can be pushed to it or pulled from it, and you'll get the "requested access to the resource is denied" error.

2
  • how to always push as public repo? Sep 3, 2019 at 9:07
  • I ran into this too: pushing a new repo resulted in "21/20 private repos". The last repo got into some sort of blocked state: even after reducing the total number of private repos, I kept receiving the access-denied error. I had to delete and re-create the repo.
    – lenz
    Oct 20, 2020 at 7:42
14

My issue was very simply using invalid characters (an extra /) in my image name:

myusername/something/image

is an invalid image name. Try myusername/something-image. Hope this helps someone.

2
  • 2
    Such an awful, unspecific error message! I was doing the same thing. Also, it won't allow repeated special characters, e.g. __.
    – ijoseph
    May 19, 2019 at 6:17
  • 1
    oy vey. knew that would cause a headache but tried anyway. error was very much a red herring.
    – bwl1289
    Oct 4, 2021 at 23:03
13

The way docker handles user IDs and repositories may be a bit confusing. Let's say you create a user account xyz on docker hub. The new account automatically establishes a namespace xyz. Then you create a repository called myrepo. The repository name will actually be xyz/myrepo.

To push an image you should do:

docker push docker.io/xyz/myrepo

You can add ":latest" or a different tag if necessary.

If you get the requested access to the resource is denied error message:

  1. Go to https://hub.docker.com/ and sign in as xyz.
  2. Click on your repository xyz/myrepo.
  3. Click on Collaborators.
  4. Add xyz as a collaborator.
1
  • so that means we can't push images from a 3rd party public repository?
    – sdinesh94
    Jun 9, 2017 at 4:51
12

OS: Ubuntu16.04

Reason: I deleted the client config file(~/.docker/config.json)

Solution:

  • Restart docker.
    service docker restart.
  • It needs to input Login info, then generates config file automatically.
    docker login --username=yourdockerhubername --email=youremail@company.com
2
  • 1
    This was the only solution that worked for me. I had upgraded my Docker and then for some reason, mvn dockerfile:push failed with this exception. Deleting this config.json fixed it.
    – anand1st
    Mar 20, 2018 at 9:23
  • This also helped me. I realized that to login either I should not put the url or if I need to specify docker hub url I should put docker login https://index.docker.io/v1/ -u=yourusername Aug 1, 2018 at 12:13
12

Yes, maybe embarrassing, but there doesn't seem to be clear documentation on this issue at all: I just signed up for Docker Pro with private repositories. I created a private repository, then tried to push to it. Got the dreaded "denied" message.

Pushing to my public repos worked fine, so I knew I was logged in correctly.

After trying everything related to Docker Hub in the prior 30 answers... I finally understood how private repos work: they're the same as public repos, but with an extra step.


When pushing to a repository - ANY repository within a Docker Hub account - you need to prefix the image:tag with your username, eg:

given the following values,

username = yourusername
image name = theimage
tag = thetag

1) tag (or commit) the local image, adding a prefix with your username:

docker tag theimage:thetag yourusername/theimage:thetag

Notes:

  • if you're in an organization, you need to double prefix the image - like so:
docker tag theimage:thetag yourusername/yourorganizationname/theimage:thetag
  • if your tag is latest, :thetag part can be left out; Docker assumes :latest if you don't enter a :thetag part

2) push the prefixed image to Docker Hub:

 docker push yourusername/theimage:thetag

OR

 docker push yourusername/yourorganizationname/theimage:thetag

THE EXTRA STEP:

Either

before step 1 above, create a private repository in your Docker Hub account.

Note that the repository name must be the same as theimage that you're planning to push. Do not include a thetag portion on the repository name. Eg, if your image is ubuntu:14.04, you would name your repository ubuntu.

Or

if you didn't create the repository in advance (which is not required!): go to your account in Docker Hub; click on the newly pushed repo, then its Settings tab - and make your repo private.


I had seen others with private repos tagging them with the two prefixes, eg xyz/abc/theimage:thetag, and I thought the 2nd prefix was something I created to mark the repo as private. Nope - that's only for organizations. Removing any 2nd prefix and setting my repo name as just theimage fixed my denied error!

Another note: each repo holds all the tagged versions of the images with the given repo's name. So, for example, ubuntu:latest and ubuntu:14.04, say, will both be in the ubuntu repo.

Fun With Docker!

10

change the image name to "username"/"image_name"

1
  • 1
    yes, it worked for me. need to specify our username in the local image name because this is not git. Feb 9, 2022 at 22:13
7

If you face this issue while using Azure Container Registry, you can solve it by logging in to your registry first.

docker login yourregistry.azurecr.io

And then tag your image to match the host name of your registry.

docker image tag yourimagename:[version] yourregistry.azurecr.io/yourimagename:[version]

And then finally push it.

docker push yourregistry.azurecr.io/yourimagename:[version]
2
  • 1
    Coming from Azure this is what helped! It is not the namespace but the hostname of the registry that is the first part of the tag!
    – binaryguy
    Aug 23, 2018 at 14:14
  • 1
    This was a lifesaver for me. Many thanks! I don't know why the Azure quick start steps don't include this. Jun 28, 2021 at 17:51
7

My answer is related to Azure DevOps similar issues I had with the following common pipeline (it is more specific but it might help somebody save time):

  1. Get sources from github
  2. Build docker image
  3. Push docker image to dockerhub

The error I received at push denied: requested access to the resource is denied sent me here.

Please be careful of the variable $(Build.Repository.Name) included in your image name. It is by default the name of the repository from github, but for your push to work it should be dockerhub_account_username/your_dockerhub_repository_name.

Replace $(Build.Repository.Name) with dockerhub_account_username/your_dockerhub_repository_name in your image name field for both build and push steps.

This is needed by the dockerhub api to know where to push the image.

7

Sometimes you may encounter this issue when you are already logged in with another account. In those cases, you will have to:

docker logout

and then

docker login  
1
  • This appeared to the issue I was facing. Basically I imported the credentials from a different machine using credentials manager and it seems like it didn't worked
    – hellowahab
    Nov 15, 2021 at 13:17
6

To those trying pushing the image to their own Nexus Repository Manager, do the below:

1) Login to your Nexus Repository Manager (Port 8443 is associated with a specific Docker host Repository)

sudo docker login xxx.mydomain.com:8443

2) Tag the image WITH YOUR NEXUS SERVER IP/DNS

sudo docker tag myimage:latest xxx.mydomain.com:8443/myimage:1.0.0

3) Push the image

sudo docker push xxx.mydomain.com:8443/myimage:1.0.0
3
  • I had an issue in jenkins docker plugin always refering to docker.io. Tagging like xxx.mydomain.com:8443/myimage:1.0.0 solved the issue. Make sure to omit the procotol and /v2/ stuff. Mar 6, 2019 at 22:53
  • why to add port. And whose port to add near xxx.mydomain.com. 8443 is fot https spring boot. What if if it is angular application Mar 7, 2019 at 10:04
  • 1
    @PSatishPatro When your repository resolves to a specific http/https port, tag will need to know where to push it (since you don't actually tell it where to go - as a parameter), as mentioned above, it needs to be the exact url as your full nexus's repository.
    – Phil
    Mar 23, 2019 at 8:31
6

It worked after I changed the "docker login https://hub.docker.com" to "docker login docker.io" and provided username & password.

Then follow below commands:

docker tag local-image:tagname new-repo:tagname

docker push new-repo:tagname

NOTE: "new-repo" will contain "Docker ID + Repo name"

Here I have created "ubuntu" repo in the Docker Hub before running below command.

Example:

docker tag alok/ubuntu:latest aloktiwari2007/ubuntu:latest

docker push aloktiwari2007/ubuntu:latest
1
  • 1
    important point for me was tagname in docker tag command it should be following - <dockeruserid>/<remote repository name>:<tag> . Same tag identifier should be used in push command . Dec 26, 2019 at 11:07
5

Simple working solution:

Go here https://hub.docker.com/ to create a PRIVATE repository with name for example johnsmith/private-repository this is the NAME/REPOSITORY you will use for your image when building the image.

  • First, docker login

  • Second, I use "docker build -t johnsmith/private-repository:01 ." to create image, and I use "docker images" to confirm the image created such as in this yellow box below: (sorry I can not paste the table format but the text string only)

johnsmith/private-repository(REPOSITORY) 01(TAD) c5f4a2861d6e(IMAGE ID) 2 days ago(CREATED) 305MB(SIZE)

  • Third, I use docker push johnsmith/private-repository:01

Done!

1
  • Why a private repo?
    – Mint
    Mar 4, 2022 at 2:42
4

Login from the app. I've been trying only from terminal with no luck.

This is version 17.06.1

enter image description here

1
  • On MacOS this was the solution for me.
    – Vagari
    Oct 19, 2017 at 18:16
4

After docker login, you need name your image with prefix.

e.g. if your username in docker-hub is Shah, the image should be:

Shah/firstimage
1
  • And, it's case-sensitive, so make sure the username is in the right case
    – leanne
    Jun 23, 2022 at 20:27
3

I had the same issue. In my case, I was login in index.docker.io and push the image to docker.io/username/image:tag.

The solution is login in the docker.io by run this command:

export CI_REGISTRY=docker.io
docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
docker push USERNAME/IMAGE:TAG

and the outputs are:

 The push refers to repository [docker.io/USERNAME/IMAGE:TAG]
 eeb7e16c6369: Preparing
 6bd09f46d0ae: Preparing
 f5a7f7a3fb28: Preparing
 07952c1df7f6: Preparing
 a4522c0d203b: Preparing
 3e207b409db3: Preparing
 3e207b409db3: Waiting
 a4522c0d203b: Layer already exists
 3e207b409db3: Layer already exists
 f5a7f7a3fb28: Pushed
 6bd09f46d0ae: Pushed
 07952c1df7f6: Pushed
 eeb7e16c6369: Pushed
 latest: digest: sha256:7ce256fa83ef1eebcaaaa460c4d73f87f2adf304bc6e6c1b83a19d987cd61ad5
size: 1579
Running after_script
00:02
Saving cache
00:01
Uploading artifacts for successful job
00:02
 Job succeeded

Regards.

3

I know this question has many answers already, but none of them were helpful to me.

What I observed was that building the image was extremely fast and pushing to docker.io resulted in the error:

denied: requested access to the resource is denied

what I also noticed was that doing an

docker image ls

revealed that the latest build of my image was several days old.

I had to do a

docker container prune 

to get rid of stopped containers, and a

docker image prune -a

to get rid of old images. Then I could successfully build and push my image.

The 'denied: requested access to the resource is denied' is not from docker.io, but from local docker. Funny though that it is not failing during build.

0
3

This worked for me on Windows 10

docker login

0
2

I'm also having this issue. Turns out I'm using the free tier and trying to push more than 1 image in the private repository. Making 1 image private and the rest public worked for me.

2

In my case I was pushing to an organization where I am in a team that has admin permissions to the repository.

so my push command was: docker push org-name/image-name

I could push successfully to username/image-name but not to the organization. I triple checked the permissions. Nothing worked.

The solution was to delete the repo from docker hub and push again fresh using: docker push org-name/image-name

For what its worth, I think the repo was originally pushed before the account was converted to an organization.

2

I really hope this helps somebody (who looks to the final answers first as myself):

I continuously tried to type in

docker push user/repo/tag

Instead

docker push user/repo:tag

Since I also made my tag like this:

docker tag image user/repo/tag

...all hell broke lose.

I sincirely hope you don't repeat my mistake. I wasted like 30 mins on this...

Not the answer you're looking for? Browse other questions tagged or ask your own question.