795

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

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Keyur Shah
  • 11,043
  • 4
  • 29
  • 48

69 Answers69

1229

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
Nam G VU
  • 33,193
  • 69
  • 233
  • 372
Webert Lima
  • 13,197
  • 1
  • 11
  • 24
  • 71
    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 02 '17 at 23:38
  • 1
    hii i follow your command got Error ---Error response from daemon: No such image: ubuntu-nodejs:latest – Yash Apr 12 '17 at 11:04
  • 66
    This answer should not have been marked as accepted! The solution provided clearly does not work as others have indicated. – SamDevx Apr 30 '17 at 03:11
  • 9
    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 --username=". Post this, "docker push" worked as expected. – Devesh Chanchlani May 16 '17 at 14:07
  • 4
    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 '17 at 21:26
  • 1
    I think its better to follow the official instructions: https://docs.docker.com/docker-cloud/builds/push-images/ for me I did not do the `docker login` command and thats why it was not working for me. – Charlie Parker Oct 07 '17 at 18:50
  • 1
    Not sure if this could help you guys. I have created a repository on Docker Cloud yoursername/netcoreapplicacion1, go to console, `docker login`, locally tag from your local app to remote `docker tag netcorewebapplication1:dev yoursername/netcorewebapplication1` and finally `docker push yourusername/netcorewebapplication1`. – Junior Mayhé Feb 15 '18 at 20:02
  • Make sure the usernames match – Gopalakrishnan Subramanian Jul 31 '18 at 00:37
  • Thnx Man. Solved my issue. I put my own DockerHub name , when I tried to Build and Push to DocketHub. – Reza Dec 14 '18 at 15:26
  • 1
    haha. I would help tons of ppl if you put "docker login" to the beginning of the answer. – ses Dec 29 '18 at 01:55
  • you get the EXACT same error if you try pushing to a private docker hub organization that doesn't have any more repo slots for your price plan – Jordan Jan 09 '19 at 22:04
  • I had to do dockerUserName/dockerRepoName:dockerImageTagName because doing as you suggest didn't work : dockerUserName/dockerRepoName/dockerImageTagName – Nk54 Jan 24 '19 at 00:51
  • Thanks man! Straight forward solution. I am using `Docker Desktop - Version 2.0.0.3 (31259)`. Even though the docker is showing running, my user account is not actually signed in with the dockerhub account. After signing in, the push worked for me. I think the status is about the `Docker Desktop suite running locally`. – bh4r4th Mar 22 '19 at 02:15
  • For those running into issues. It's possible you need to explicitly add the port number in your docker login command, ie `docker login :` as `docker login` or `docker login ` may connect without issue, but when it comes time to push images, you'll get the same error as OP. – Arthur Weborg Jan 24 '20 at 19:37
  • It worked as specified for me no issues. And a tutorial I am using said the same thing. – fergjo Apr 21 '20 at 20:15
  • `sudo docker login` AND enable X11 forwarding if you're on ssh – Alsushi Jun 16 '20 at 16:14
  • `docker image tag --help` would give you the answer on what exactly should do: ```Usage: docker image tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG] Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE``` and of course use `docker logout` and `docker login` accordingly. – darmis Jul 14 '20 at 11:38
  • This worked for me whithout changing the repo to private – Gjaa May 07 '21 at 22:48
  • this is annoying. Why do I need to do this if I already logged in with docker login? – Charlie Parker Jun 14 '22 at 16:12
  • Logout then login fixed my issue. – Nasser Ali Karimi Nov 10 '22 at 09:28
  • hi, how did you fix this issue? – effedici Jan 10 '23 at 17:27
285

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 darlin

  2. Tag your image build

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

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

I tagged as below :

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

    docker push darlin/dockerhub:myfirstimagepush

And it was successfully pushed to my personal docker repo.

Venu S
  • 3,251
  • 1
  • 9
  • 25
244

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

MatPag
  • 41,742
  • 14
  • 105
  • 114
Dean Wu
  • 2,565
  • 2
  • 7
  • 4
  • 18
    FWIW, I was getting _error getting credentials_ on `docker login`. `sudo docker login` worked for me. This allowed me to push my private repo. – johnsampson Mar 14 '17 at 17:34
  • 2
    Apparently the Docker webinar is outdated. – Luís de Sousa May 30 '17 at 18:13
  • Caveat with sudo - see my answer – rhoerbe Aug 27 '18 at 09: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 '21 at 04:56
  • Must use ASL logging (which requires CGO) if running as root Error saving credentials: error storing credentials - err: exit status 1, out: ` – Namwanza Ronald Mar 27 '23 at 08:37
  • FWIW, on my shared dev server the root user was logged in as a different user from someone else, so `sudo docker push` would try to push to the other user's account. Running `docker push` would instead use 'my' docker hub account. – Philipp Apr 12 '23 at 03:25
72

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

MSingh
  • 729
  • 5
  • 4
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
Erick Boshoff
  • 1,443
  • 2
  • 18
  • 30
  • 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 09 '20 at 09:32
27

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.

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
  • #without the specific login command above, kept getting access error when pushing, even though i had logged in via command line – Vandana Chadha Oct 15 '20 at 03: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 '21 at 07:06
22

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
Hanamant Jadhav
  • 627
  • 7
  • 12
21

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.

Hito
  • 820
  • 8
  • 10
  • 1
    Yeah with logout, it comes back working for me. Thank you! – Nam G VU Mar 04 '20 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. – Markus Bawidamann Jun 05 '21 at 08:37
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.

Jay Patel
  • 2,341
  • 2
  • 22
  • 43
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

Keet Sugathadasa
  • 11,595
  • 6
  • 65
  • 80
jsight
  • 27,819
  • 25
  • 107
  • 140
16

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.

patrickbadley
  • 2,510
  • 2
  • 29
  • 30
  • 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 '19 at 06:17
  • 1
    oy vey. knew that would cause a headache but tried anyway. error was very much a red herring. – bwl1289 Oct 04 '21 at 23:03
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.

rghazali
  • 185
  • 2
  • 10
  • how to always push as public repo? – Raja Anbazhagan Sep 03 '19 at 09: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 '20 at 07:42
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.
Paulo Merson
  • 13,270
  • 8
  • 79
  • 72
13

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!

leanne
  • 7,940
  • 48
  • 77
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
Song
  • 593
  • 9
  • 21
  • 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 '18 at 09: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` – Ronan Quillevere Aug 01 '18 at 12:13
10

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

Alex Skotner
  • 462
  • 1
  • 8
  • 18
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]
hendryanw
  • 1,819
  • 5
  • 24
  • 39
  • 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 '18 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. – Alan Cabrera Jun 28 '21 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.

Gabriel P.
  • 3,400
  • 2
  • 32
  • 23
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  
radiopassive
  • 556
  • 1
  • 5
  • 15
  • 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 '21 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
Phil
  • 87
  • 1
  • 2
  • 9
  • 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. – Himmet Avsar Mar 06 '19 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 – Satish Patro Mar 07 '19 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 '19 at 08: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
Alok Tiwari
  • 354
  • 3
  • 8
  • 1
    important point for me was tagname in docker tag command it should be following - /: . Same tag identifier should be used in push command . – Tanmay Patil Dec 26 '19 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!

Dung
  • 19,199
  • 9
  • 59
  • 54
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

Ignacio Pascual
  • 1,895
  • 1
  • 21
  • 18
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
reck mi
  • 71
  • 3
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.

noraj
  • 3,964
  • 1
  • 30
  • 38
TheRoadrunner
  • 1,281
  • 14
  • 34
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.

Muhammad Dyas Yaskur
  • 6,914
  • 10
  • 48
  • 73
3

This worked for me on Windows 10

docker login

Cyebukayire
  • 795
  • 7
  • 14
3

Have a docker file and requirement is to build an image and push the same to Docker hub immediately

  1. Login to Docker hub
    sudo docker login -u your_username
    Enter password

  2. Build the image
    sudo docker build -t your_username/demorepo:1.0
    Above, there is no mention of image name as your_username/demorepo is a repo in docker hub. Tagged name is 1.0

  3. Push the image
    sudo docker push your_username/demorepo:1.0

To push already existing image to Docker hub

  1. Login to the Docker hub
    sudo docker login -u your_username
    Enter password

  2. Tag your image(suppose your image is named as test_docker:1.0)
    sudo docker tag test_docker:1.0 your_username/demorepo:firstpush
    Above, firstpush is the tag name given to your image, test_docker with 1.0 Tag.
    IMPORTANT : (While tagging, the image name is not mentioned)
    Now in docker images you will have 2 images, one says test_docker 1.0 and the other your_username/demorepo firstpush

  3. Push the image
    sudo docker push your_username/demorepo:firstpush

3

Had to tag it with my username like

docker login

docker tag imageName username/imageName

docker push username/imageName

Only this worked for me!

kittu
  • 6,662
  • 21
  • 91
  • 185
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.

Shige
  • 176
  • 2
  • 6
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.

schmidlop
  • 1,356
  • 16
  • 31
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...

GeorgiG
  • 1,018
  • 1
  • 13
  • 29
2

I'm slow to add yet another answer, but the accepted answer and remaining answers mentioning docker login are missing an edge case to solve the issues others are stating in comments.

docker login <private-repo-host>:<port>

Emphasis on the port needing to be entered is likely the solution for those still searching. docker login or docker login <private-repo-host> may connect without issue, but when it comes time to push images, you'll get the same error as OP.

That is, you can connect w/o defining host or port and still get the:

...

Login Succeeded

In my case, I am using a self hosted GitLab's built in docker-registry, which was setup to use port 4567. It may be adventagous to verify what port the registry must be accessed from. Without specifying said port docker login <our.gitlab.host> would login successful, but give the same issue the OP inquired about:

...

The push refers to repository [...]

denied: access forbidden

If you're using docker.io/dockerhub you're likely not going to have this problem, but if you have a self hosted/private registry solution the probability increases you need to explicitly login using both the host and port for the docker registry.

Arthur Weborg
  • 8,280
  • 5
  • 30
  • 67
2

the easiest way is used docker desktop(for Windows 10 or above and mac)

first signup to docker hub by providing dockerID

then click docker desktop icon in your machine and ->Preferences -> then login to it using docker hub docker/id and password.

enter image description here

Jayani Sumudini
  • 1,409
  • 2
  • 22
  • 29
2

I also encountered this error message, using the Gitlab registry. The difference was that I was attempting to change the name of the image from previous builds. The problem there, is that the registry for the image being pushed did not exist, because the new name of the image didn't match any of the projects in my group.

TLDR: In Gitlab, the image name has to match the project name.

glimmbo
  • 143
  • 10
2

I had similar problem from Azure pipeline. I missed to add docker-id in repository section.

From Azure, while pushing, if name alone is used e.g. <repo-name>, may not work. It need fully qualified repo name which also include docker-id.

Use

repository: '<docker-id>/<repo-name>'

instead of

repository: '<repo-name>'

Pipeline snippet:

- task: Docker@2
  inputs:
    containerRegistry: 'service-connection-name'
    repository: '<docker-id>/<repo-name>'
Digital_Reality
  • 4,488
  • 1
  • 29
  • 31
2

Step 1: Change privacy mode in the docker account

https://hub.docker.com/settings/default-privacy enter image description here

Step 2: Run the below commands which are mentioned in the screenshort:

enter image description here

  • docker images
  • docker tag <<TAG_ID>> <<USER_NAME>>/<<IMAGE_NAME>>:latest
  • docker login docker.io
  • docker push <<USER_NAME>>/<<IMAGE_NAME>>:latest

output: enter image description here

Abdullah
  • 2,393
  • 1
  • 16
  • 29
2

Many answers talked about login. Of course login is needed, if the error is still not solved after login, look for the The push refers to repository. In my case, it was trying to push to

[docker.io/library/<myimage>]

After I tagged the repo with <account_name>/<repo_name>:<tag> it worked.

docker tag mynginx_image:latest <myaccount>/mynginx:latest
docker push <myaccount>/mynginx:latest

Then it changed to

The push refers to repository [docker.io/<myaccount>/mynginx]

Suresh Ganta
  • 135
  • 1
  • 5
2

For others who have a similar problem (but they are already logged in):

just make sure to rename your tag:

docker tag whatEverNameForImage:tag YourUserName/whatEverNameForImage:tag

and then push the latest

docker push YourUserName/whatEverNameForImage:tag
  • 1
    This question has over 60 answers. Yours appears to be identical to [this one from yesterday](https://stackoverflow.com/a/76532853/19068). What makes it worth adding? – Quentin Jun 23 '23 at 15:45
1

If it still fails after docker login, make sure the repository you're trying to push to was created in the first place.

louis_guitton
  • 5,105
  • 1
  • 31
  • 33
1

So, incase it is helpful to anyone...
I had this same issue and here is what my issue and the FIX was.

  • I had a computer on my test network named 'galaxy'.
  • I setup docker registry using the following run command:
    sudo docker run -d 
    --restart=always \
    --name registry \
    -v /srv/registry/certs:/certs \
    -v /srv/registry/storage:/var/lib/registry \
    -e REGISTRY_HTTP_ADDR=0.0.0.0:443 \
    -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/galaxy.cert \
    -e REGISTRY_HTTP_TLS_KEY=/certs/galaxy.key \
    -p 443:443 \
    registry:2
    

    Then I was trying to push an image to galaxy from a laptop on the network so I did this:

    docker login galaxy
    

    This would give me an error that would say:

    Login did not succeed, error: Error response from daemon: 
        Get https://galaxy/v2/: x509: certificate signed by unknown authority
    

    Oddly the fix to this issue was to do a login like this:

    docker login galaxy:443
    

    That resulted in a successful login.

    So then I tried to push the image from my laptop to 'galaxy'.
    I had already created a tag for my image that looked like this:

    galaxy/myImage:0.0.1
    

    So I tried to push it doing this:

    docker push galaxy/myImage:0.0.1
    

    To which I got the reply:

    The push refers to repository [docker.io/galaxy/myImage]
    7ab460574f86: Preparing 
    1aecaf56754d: Preparing 
    1df1b5f06ca4: Preparing 
    denied: requested access to the resource is denied
    

    Oddly enough I discovered the fix for this was to first tag the image as follows:

    docker tag myImage:0.0.1 galaxy:443/myImage:0.0.1
    

    ... and then do the push like this:

    docker push galaxy:443/myImage:0.0.1
    

    So for some reason I had to include the port in the tag as a required part of the repository name.



    Hope this helps others.

  • Deoji
    • 31
    • 3
    1

    all previous answer were correct, I wanna just add an information I saw was not mentioned;

    If the project is a private project to correctly push the image have to be configured a personal access token or deploy token with read_registry key enabled.

    source: https://gitlab.com/help/user/project/container_registry#using-with-private-projects

    hope this is helpful (also if the question is posted so far in the time)

    AtomiX84
    • 182
    • 1
    • 12
    1

    This answer is as much for my future self as for anyone else. I have encountered this exact problem when I am logged in correctly, but I am attempting to push to a private repo when my number of private repos is greater than or equal to the limit allowed by my plan.

    I'm not exactly sure how I was able to create too many private repos, but if my plan includes 5 private repos, and somehow I have 6, then this is the error that I will receive:

    denied: requested access to the resource is denied

    In my case it's possible that I ended up with too many private repositories because I have my default visibility set to private:

    Default Visibility

    This is where you determine how many private repos you can have:

    Billing Plans

    Once I made the problematic repo public, the issue became apparent:

    Make Repository Private 5 of 5

    Matthew James Briggs
    • 2,085
    • 2
    • 28
    • 58
    1

    I came here with the same above message, but from Azure DevOps.

    In my case, I was using docker-compose, not just docker, and writing the build pipeline in yaml.

    - task: DockerCompose@0
      displayName: 'Push services'
      inputs:
        azureSubscription: '$(Parameters.azureSubscriptionEndpoint)'
        azureContainerRegistry: '$(Parameters.azureContainerRegistry)'
        dockerComposeFile: '$(Parameters.dockerComposeFile)'
        additionalDockerComposeFiles: |
          docker-compose.release.yml
          docker-compose.ci.yml
        dockerComposeFileArgs: 'PublishFolder=publish'
        action: 'Push services'
        additionalImageTags: '$(Build.BuildId)'
        includeLatestTag: true
    

    The message I got was specifically saying that it was trying to push to docker.io, which was not what I wanted. I had intended this to go to my Azure Container Registry.

    Thing that was missing was this line under inputs:

    containerregistrytype: Azure Container Registry
    

    The existing pipeline wizard that built the yaml above did not have this line at all. Hopefully this helps someone else pulling their hair out over Azure DevOps.

    Kilanash
    • 4,479
    • 1
    • 14
    • 11
    1

    TL;DR docker login did not work for me on macOS but docker login from the app worked

    When used directly from the terminal, the command docker login successfully asked for my credentials and after I entered them correctly (remember no email, only the docker ID will work) it announced login succeeded but any request to push would end up in a denied: requested access to the resource is denied

    However, when I logged in from the macOs docker app that was running (cf from the icon in the toolbar) it worked. So there may be some inconsistence between docker login and the running docker app/daemon

    Cyril Duchon-Doris
    • 12,964
    • 9
    • 77
    • 164
    1

    Do not allow mislead towards tag name.
    My approach to solve this:

    Command 1(Create Tag): docker tag my-nginx:latest rsachde/nginx-repository/trys:1.0 (Didn't push)
    Command 2(Push): docker push rsachde/nginx-repository/try:1.0 
    

    Output:

    denied: requested access to the resource is denied


    Command 1.1(Create Tag): docker tag my-nginx:latest rsachde/nginx-repository/:trys 
    Command 2.2(Push): docker push rsachde/nginx-repository:trys 
    

    Output:

    trys: digest: sha256:405b6f0ae25772ef71b8f59fd6a56ff9b426f50bd24bac2b5db41f65efd3387c size: 1365

    Misleading is Tag, make sure you understand that.

    סטנלי גרונן
    • 2,917
    • 23
    • 46
    • 68
    Ria Sachdeva
    • 113
    • 6
    1

    After giving each of the high score solution a try, I still got no luck.

    Not until I changed my focus and search keyword to include my credential helper - pass.

    If this is a similar case for you (using any kind of docker-credential-helpers and just followed a general guideline to setup), try to review the steps and see if anything has been missed.

    For example, I'm using pass as the credstore for docker, the step to insert my dockerhub account password for a dedicated pass-name docker-credential-helpers/docker-pass-initialized-check had been missed when I just followed the top search results to setup pass.

    After issuing the following command, docker push finally showed some mercy on me.

    pass insert docker-credential-helpers/docker-pass-initialized-check
    

    See this answer for more details.

    carusyte
    • 1,549
    • 17
    • 21
    • Thanks a lot. I didn't thought this step was crucial, I thought that was a random custom entry name and a random password. – noraj Jan 02 '22 at 19:10
    1

    This might be very specific to DigitalOceans Container Registry but maybe it helps:

    In my case my pipeline triggers a cleanup job (doctl registry garbage-collection start) after the docker push , which put the registry in read only mode (see doc). So the next push while the cleanup job is active will get denied: requested access to the resource is denied.

    If doctl registry garbage-collection get-active returns a 404 the job finished and docker push will complete successfully.

    Colin
    • 1,112
    • 1
    • 16
    • 27
    • 1
      This ended up being the same issue for me. I didn't realize that garbage-collection triggered read-only mode so I was scratching my head at the error message. Thanks! – ChrisC Mar 07 '21 at 15:29
    1

    Push all tags

    use -a to push. s.t. docker push username/image -a

    access denied is likely due to docker repository permission not public (u can double check)

    U need to pull to check if it's ok.

    View in hub.docker.com

    Open 'Tags' to view all available tags after success push

    CodeFarmer
    • 2,644
    • 1
    • 23
    • 32
    1

    The only thing that finally worked for me was creating a public repository in docker hub and tagging the local image with the same name, and adding my userID in collaborators {in dockerhub} and finally pushing it.

    dilip_nikhil
    • 369
    • 3
    • 6
    1

    If you are already logged in and still if you get the error. Please follow the steps,

    PS C:\Users\rohit\Docker> docker logout
    Removing login credentials for https://index.docker.io/v1/
    
    PS C:\Users\rohit\Docker> 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: rohithpoya
    Password:*****************
    Login Succeeded
    
    Logging in with your password grants your terminal complete access to your account.
    For better security, log in with a limited-privilege personal access token. Learn more at https://docs.docker.com/go/access-tokens/
    
    PS C:\Users\rohit\Docker> docker push rohithpoya/mongo-enterprise:5                                                                                                                                                                       
    The push refers to repository [docker.io/rohithpoya/mongo-enterprise]                                                                                                                                                                        83ee27b8fe98: Pushed
    
    rohithpoya
    • 865
    • 7
    • 20
    1

    I faced the same issue while creating a CI pipeline in Azure Devops to build and push docker image to Docker Hub. The mistake that I was making was providing wrong entry in Container repository section.

    In buildAndPush task I was giving repository name in Container repository field. Actually repository name should be appended with Docker Hub username/. So for example, your username is myuser and repository name is test then provide entry as myuser/test. As soon as I corrected this, the pipeline worked successfully and image was pushed to my docker hub repository

    Hitesh
    • 703
    • 1
    • 9
    • 14
    1
    docker logout
    docker login
    (enter username and password)
    docker login
     docker tag {imageName} {dockerUserId}/{imageName}
    docker push  {dockerUserId}/{imageName}
    
    jmoerdyk
    • 5,544
    • 7
    • 38
    • 49
    Raunak ali
    • 21
    • 2
    0

    rename your image to username/image-name docker tag your-current-image/current-image dockerhub-username/some-name:your-tag(example: latest)

    Italo José
    • 1,558
    • 1
    • 17
    • 50
    0

    Try sign out of "Docker for Windows" application and sign out of https://hub.docker.com/ site and after perform "docker login" and "docker push". It helped for me.

    Vladimir
    • 101
    • 1
    • 2
    0

    docker login from the command prompt did not work. I kept getting "requested access to the resource is denied" when trying to push.

    After signing in to the docker for windows app itself, docker push worked just fine. Hope this helps someone.

    0

    In case anyone else runs into this - the cause, in my case, was that I was using the (deprecated) docker compose approach to push images. Switching to the expected docker push resolved the issue for me.

    Dan Nissenbaum
    • 13,558
    • 21
    • 105
    • 181
    0

    Another (pretty smart) reason for this: you're out of private repos with your plan.

    Costa Shapiro
    • 524
    • 1
    • 3
    • 8
    0

    In my case sudo -E failed with this message. The resolution was to provide access do docker without sudo (create a group docker, add the (Jenkins) user to the group, set the group on /var/run/docker.sock). Now docker push does not need sudo, and it works.

    rhoerbe
    • 463
    • 1
    • 4
    • 17
    0

    My problem on git was the project permission configuration. I've fixed it by enable the "Container registry" in settings->general->Visibility, project features, permissions and enable Container Registry for my project (link):

    enter image description here

    Manuel Schmitzberger
    • 5,162
    • 3
    • 36
    • 45
    0

    Docker hub plans have restrictions on number of private repositories that a namespace can use. For instance, the free plan will only allow you to use one private repository at any point in time for an account.

    If you are under your plan limits, then your push will succeed. Otherwise, an empty repository with an appropriate tag will be created but the image itself wont be pushed.

    In my case, I created the repositories as public using the web console prior to pushing the images.

    Raja Anbazhagan
    • 4,092
    • 1
    • 44
    • 64
    0

    I got the same error in ibmcloud. I added namespace and then tried to push my image, it resolved the issue.

    ibmcloud cr namespace-add txts
    
    Hasta Dhana
    • 4,699
    • 7
    • 17
    • 26
    Malar Kandasamy
    • 839
    • 2
    • 10
    • 17
    0

    I was struggling with the docker push, both using the Fabric8 Maven plugin (on Windows 10), and directly calling docker push from the command line.

    Finally I solved both issues the same way.

    My repo is called vgrazi/playpen. In my pom, I changed the docker image name to vgrazi/playpen, as below:

    <plugin>
      <groupId>io.fabric8</groupId>
      <artifactId>docker-maven-plugin</artifactId>
      <version>0.31.0</version>
      <configuration>
         <dockerHost>npipe:////./pipe/docker_engine</dockerHost>
         <verbose>true</verbose>
         <images>
           <image>
             <name>vgrazi/playpen</name>
             <build>
               <dockerFileDir>${project.basedir}/src/main/docker/</dockerFileDir>
                             ...
    

    That let me do a mvn clean package docker:build docker:push from the command line, and at last, the image appeared in my repo, which was the problem I was trying to solve.

    As an aside, to answer the OP and get this to work directly from the command line, without Maven, I did the following (PS is the PowerShell prompt, don't type that):

    PS docker images
    vgrazi/docker-test/docker-play                playpen             0722e876ebd7        40 minutes ago      536MB
    rabbitmq                                      3-management        68055d63a993        10 days ago         180MB
    PS docker tag 0722e876ebd7 vgrazi:playpen
    PS docker push vgrazi/playpen
    

    and again, the image appeared in my docker.io: repo vgrazi/playpen

    Victor Grazi
    • 15,563
    • 14
    • 61
    • 94
    0

    Docker login parameters in ~/.docker/config.json should be properly set (which is done automatically after login)

    1) Login without passing SERVER parameter:

    $ echo "<password>" | docker login -u foo --password-stdin
    

    After successful login it results as follows in ~/.docker/config.json and pushing image succeeds.

    ***
    "https://index.docker.io/v1/": {
        "auth": "YWNhcm***"
    }
    ***
    

    2) Login with passing SERVER parameter as index.docker.io

    $ echo "<password>" | docker login index.docker.io -u foo --password-stdin
    

    After successful login it results as follows in ~/.docker/config.json and pushing image fails.

    ***
    "index.docker.io": {
        "auth": "YWNhcm***"
    }
    ***
    
    Akif
    • 6,018
    • 3
    • 41
    • 44
    0

    I was getting the same error. Unfortunately, the error was due to using sudo before docker push. Also you might need to remove the repositories from dockerhub since there is a limit for the number of repos which you can have. And, please try docker logout and then docker login

    Raunak Agrawal
    • 148
    • 1
    • 4
    0

    I had a similar issue, i resolved it by creating a repository with the same image name and then pushed it to the docker, it worked

    Vibin
    • 155
    • 1
    • 4
    0

    Here step

     1. Logout in Dockerhub website
     2. Login Dockerhub web
     3. Login Dockerhub  desktop
     4. Open with Dockerhub desktop
     5. re push it working well!
    
    Trinh Hieu
    • 379
    • 3
    • 6
    0

    I was stuck in the same issue but how I fixed I will share the step. The step which I was doing I was using wrong Docker ID while creating the tag. I found out that Docker ID is the username while we register on Docker Hub.

    Follow the below link & follow the instructions step by step: Push the Docker image

    rahul sharma
    • 111
    • 4
    -3

    I had the exact same issue. I would highly recommend to go through this blog.

    My issue was more related to ACR. docker client would refer to the config.json file were your SP credential file would be stored (Role Owner).

    Sections of the blog that helped me in the solution are:

    • docker image ls
    • docker tag .azurecr.io/:v1
    • docker push .azurecr.io/:v1

    Before this action I also created a SP with the owner privilege.

    blackgreen
    • 34,072
    • 23
    • 111
    • 129
    Jignesh Rawal
    • 521
    • 6
    • 17