Docker Push error - unauthorized: authentication required

I have been unable to do a “docker push” for the past 2 days. When I issue the push command it appears to upload the image until the very end of the process when I get the “unauthorized: authentication required” error. I can pull an image, just not push one. I have logged out and logged back in with no change. The url in my config.json is https://index.docker.io/v1/. Any help would be appreciated.

1 Like

The image has to be tagged appropriately to push. Looks like the images is being pushed to a different repository instead of the repository owned by you.

Here is an example, I am using python image from docker hub:

This command fails because you are not authorized to push the image to the default repository

$ docker push python
The push refers to repository [docker.io/library/python]
29778035860f: Layer already exists
fc88d2431f4d: Layer already exists
1dc1b82fa010: Layer already exists
09e3fd9cf357: Layer already exists
138d1921c15b: Layer already exists
d714f65bc280: Layer already exists
fd6060e25706: Layer already exists
d7ed640784f1: Layer already exists
1618a71a1198: Layer already exists
errors:
denied: requested access to the resource is denied
unauthorized: authentication required

In order for this to be successful, the image has to be tagged with the username

$ docker tag python avinashdesireddy/python

The tagged image will appear as follows

$ docker images
REPOSITORY                      TAG                 IMAGE ID            CREATED             SIZE
davinashreddy/docker-tutorial   latest              f4dc35a9b867        25 hours ago        943MB
avinashdesireddy/python         latest              2fbd95050b66        4 days ago          927MB
python                          latest              2fbd95050b66        4 days ago          927MB

Now the new image owned by the user can be pushed

$ docker push avinashdesireddy/python
The push refers to repository [docker.io/avinashdesireddy/python]
d44ff7a4fe91: Mounted from library/python
f0471e0a730a: Mounted from library/python
9b544a6417e1: Mounted from library/python
21c09f8186d9: Mounted from library/python
56a89222b908: Mounted from library/python
a89464ad2a8f: Mounted from library/python
76dfa41f0a1d: Mounted from library/python
c240c542ed55: Mounted from library/python
badfbcebf7f8: Mounted from library/python
latest: digest: sha256:56a77760cd79f566cec67c188762bf26d10f444767b5ef27744711b08553a653 size: 2218
AD-MBPt13-2018:dotfiles avinashdesireddy$

I had the same problem. I had been successful in creating the private repository previously and pushing an image to it. After a month I tried again multiple times with the same result: unauthorized:authentication required. It was really frustrating as it would only give that error after appearing to have successfully pushed the 3GB image to the repo. I had made sure I was properly logged in to Docker using docker login (after logging out and restarting docker desktop).

It was an easy fix even though it took me 3 hours to find it. I had two accounts on my docker login, one for personal and one for work. I was pushing the image to the wrong account. I needed to set it on the docker icon on the system tray to the business repo as it defaulted to my personal repo in the same account.

I had some issues pushing a large-ish image on a slow internet connection - docker’s authentication would time out before the push had finished. I’m trying this as a workaround.

docker push username/repo:tag &
## that sets it running as a background command, then
while sleep 5; do docker login -u username -p password; done

Sadly though, that didn’t work :frowning: