Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker push: unauthorized: authentication required #645

Closed
gtirloni opened this issue Apr 18, 2016 · 34 comments
Closed

docker push: unauthorized: authentication required #645

gtirloni opened this issue Apr 18, 2016 · 34 comments

Comments

@gtirloni
Copy link

Repository is this: https://hub.docker.com/r/gtirloni/hellonode

Logout results:

$ docker logout
Remove login credentials for docker.io

Login results:

$ docker login
Username: gtirloni
Password:
Email: [email protected]
WARNING: login credentials saved in /home/user/.docker/config.json
Login Succeeded

Push image error:

$ docker push docker.io/gtirloni/hellonode:latest
Do you really want to push to public registry? [y/n]: y
The push refers to a repository [docker.io/gtirloni/hellonode](len: 1)
521e87320aa7: Preparing
unauthorized: authentication required

Drop "docker.io" from name, push image error

$ docker push gtirloni/hellonode
Do you really want to push to public registry? [y/n]: y
The push refers to a repository [docker.io/gtirloni/hellonode](len: 1)
521e87320aa7: Preparing
unauthorized: authentication required

Push to repository that doesn't exist (to ensure this is not what the unauthorized is trying to tell):

$ docker push docker.io/gtirloni/aaa
Do you really want to push to public registry? [y/n]: y
The push refers to a repository [docker.io/gtirloni/aaa](len: 0)
Repository does not exist: docker.io/gtirloni/aaa

Information:

$ docker info
Containers: 0
Images: 14
Server Version: 1.9.1
Storage Driver: devicemapper
 Pool Name: docker-docker--pool
 Pool Blocksize: 524.3 kB
 Base Device Size: 107.4 GB
 Backing Filesystem: xfs
 Data file: 
 Metadata file: 
 Data Space Used: 1.075 GB
 Data Space Total: 85.81 GB
 Data Space Available: 84.73 GB
 Metadata Space Used: 340 kB
 Metadata Space Total: 109.1 MB
 Metadata Space Available: 108.7 MB
 Udev Sync Supported: true
 Deferred Removal Enabled: true
 Deferred Deletion Enabled: true
 Deferred Deleted Device Count: 0
 Library Version: 1.02.107-RHEL7 (2015-12-01)
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.10.0-327.13.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
CPUs: 2
Total Memory: 3.703 GiB
Name: hostname
ID: XTLW:ALXW:QZXE:P7JB:IOF7:A5GH:UR34:26SV:6TFT:IVHL:OA4P:FWRQ
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
@gtirloni
Copy link
Author

gtirloni commented Apr 18, 2016

Same error that happened on CentOS 7.2 with Docker 1.9.1 is also happening on another box running Fedora with Docker 1.10.3

@opax7
Copy link

opax7 commented Apr 20, 2016

Same issue happening to me:
Docker version 1.9.1, build 78ee77d/1.9.1
CentOS Linux release 7.1.1503 (Core)

@gtirloni
Copy link
Author

Talked to people in #atomic and it looks like this is a regression in the CentOS package. The RPM from Docker doesn't have this issue. v1.10.2 solves it but it has not been pushed to updates yet. You can try fixing config.json manually.

@gtirloni
Copy link
Author

@dkhaws77 your ~/.docker/config.json should use "https://index.docker.io/v1/" instead of "docker.io" as the registry name.

@opax7
Copy link

opax7 commented Apr 21, 2016

Perfect. Thanks @gtirloni.

@seanjensengrey
Copy link

seanjensengrey commented Jun 23, 2016

I believe this issue and distribution/distribution#1679 both involve a lack of syntax checking for doing a build enabling deep pebkac'ry

docker build -t <user>/<repo>:<tag>
docker push <user>/<repo>:<tag>

For example

docker build -t seanjensengrey/test:foo .
docker push seanjensengrey/test:foo

succeeds without the unauthorized: authentication required error.

Previously I was doing

docker build -t seanjensengrey:test .

and when pushing

$ docker push seanjensengrey:test
The push refers to a repository [docker.io/library/seanjensengrey]
d85489d72cf0: Preparing 
5f70bf18a086: Preparing 
737f40e80b7f: Preparing 
82b57dbc5385: Preparing 
19429b698a22: Preparing 
9436069b92a3: Waiting 
unauthorized: authentication required

@ghost
Copy link

ghost commented Jun 30, 2016

@dkhaws77 @gtirloni My config.json file contains the "https://index.docker.io/v1/" instead of "docker.io" but still sam problem of unauthorized: authentication required

@opax7
Copy link

opax7 commented Jul 1, 2016

Try bouncing Docker after making the change to the url

On Thu, Jun 30, 2016 at 6:58 AM, baibhavVishal [email protected]
wrote:

@dkhaws77 https://github.com/dkhaws77 @gtirloni
https://github.com/gtirloni My config.json file contains the "
https://index.docker.io/v1/" instead of "docker.io" but still sam problem
of unauthorized: authentication required


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#645 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ARtJTThRwsvqFprxQb2v5uw5A7hLA7NHks5qQ69vgaJpZM4IKESF
.

@YangLeoZhao
Copy link

YangLeoZhao commented Aug 11, 2016

@baibhavvishal do you have a repo on docker hub? i had the same issue. You need to create a repo first which will be in the format of {username}/{project_name} and then you need to name your image the same way.

Hopefully that fixes your problem

@cuiyz
Copy link

cuiyz commented Sep 29, 2016

@seanjensengrey Totally worked out!!! Thannks man!

@RobinsChens
Copy link

@gtirloni Thanks a lot,it well done

@vergil1113
Copy link

@seanjensengrey hi,l meet a problem ,could you help me..
i use your method but it didn`t work

@subbu05
Copy link

subbu05 commented Jan 20, 2017

Same issue - Unable to login.
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: [email protected]
Password:
Error response from daemon: Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password
SUMALEPA-M-91PC:goHttp sumalepa$ docker version
Client:
Version: 1.13.0
API version: 1.25
Go version: go1.7.3
Git commit: 49bf474
Built: Wed Jan 18 16:20:26 2017
OS/Arch: darwin/amd64

Server:
Version: 1.13.0
API version: 1.25 (minimum version 1.12)
Go version: go1.7.3
Git commit: 49bf474
Built: Wed Jan 18 16:20:26 2017
OS/Arch: linux/amd64
Experimental: true

@jmhmd
Copy link

jmhmd commented Feb 3, 2017

Having the same problem- uploading my first self-built image, and it seems like it's working (multiple layers have uploaded), but the last three layers always upload, then it spits out the error:

docker push jmhmd/my-image
The push refers to a repository [docker.io/jmhmd/my-image]
b28f65f98f4f: Pushing [==================================================>] 295.1 MB
13261332ad17: Layer already exists
6ff9ce096040: Layer already exists
c3a96f311344: Layer already exists
ced802257d13: Layer already exists
e71c5b4dd1c2: Layer already exists
bed565f4d5c9: Layer already exists
ad525b66cc83: Layer already exists
ddd0e1b85d53: Layer already exists
d102d2b38820: Layer already exists
5ca6c7a78955: Pushing [==================================================>] 226.8 MB
129a26692c2d: Layer already exists
09ac8f439007: Layer already exists
019e6bc69238: Layer already exists
345f24a83e76: Layer already exists
221e2f80fc13: Pushing [==================================================>] 630.7 MB
5eb5bd4c5014: Layer already exists
d195a7a18c70: Layer already exists
af605e724c5a: Layer already exists
59f161c3069d: Layer already exists
4f03495a4d7d: Layer already exists
unauthorized: authentication required

Docker config looks like:

{
	"auths": {
		"https://index.docker.io/v1/": {
			"auth": "somekeythatactuallyexists="
		}
	}
}

I'm on latest macOS. Thank you for any help.

@phistakis
Copy link

i also get something like what @jmhmd showed:

$ docker push :
The push refers to a repository []
b9b0140bc5d8: Pushing [==================================================>] 136.4 MB
8bf3728e9551: Layer already exists
4e23b6e09582: Layer already exists
e63ae5c3fee6: Layer already exists
bfd40abcc21b: Layer already exists
d4b742028f8f: Layer already exists
af6c1fd1361a: Layer already exists
06eeff601a99: Layer already exists
3cd27dffd3b9: Layer already exists
83c5e5aaf861: Layer already exists
4b1d9cae4d36: Layer already exists
9169d8d0fed4: Pushing [===================================> ] 128.8 MB/179.1 MB
18952bb7f5a0: Layer already exists
ae9e7022ec53: Layer already exists
b28618edc8e2: Layer already exists
08d563bae0e2: Pushing [==================================================>] 106.5 MB
9e30d303ecc3: Layer already exists
688741e9aae3: Pushing [================> ] 199.5 MB/622 MB
3399b70639d9: Layer already exists
47e1c0953416: Layer already exists
a0099a89f519: Layer already exists
a3a9332e8b72: Layer already exists
e22ada38f4ec: Pushing [==================================================>] 71.06 MB
34e7b85d83e4: Layer already exists
unauthorized: authentication required

this is a very large build, and the upload bandwidth isn't that great, so i'm guessing it might have something to do with some sort of timeout...

@vivekkrdubey
Copy link

I faced the same issue while starting out with my first docker push. and surprisingly this issue appears only on Client Node but works on Docker Host (where Dameon Runs).

One observation though, please make sure that you are using same Docker_username on both HOST and Client nodes.
So if you are using docker login then do that on Docker Host once before trying out on Client.

@rajaol
Copy link

rajaol commented Mar 19, 2017

My config file after login
cat ~/.docker/config.json
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}

Tried many times to push but always failed after 100% .. :(
docker push Username/image:latest

When I done it for the first time with another image it was successful.

@nunodio
Copy link

nunodio commented Jun 16, 2017

This issue is closed, but I really don't understand if anyone already solved the issue described by @phistakis and @jmhmd ?

@nongdenchet
Copy link

@phistakis did you solve your problem? I am currently facing the problem... sometime the push is successful but sometime not.. it is a large push and wasting a significant amount of time

@elzbth
Copy link

elzbth commented Jul 31, 2017

Same here, having the same issue with Docker for Mac. Push fails for images >1G

@abitrolly
Copy link

If you're pushing to organization repository make sure you've added yourself in it to the Collaborators with write access.

@almostsultry
Copy link

Having the same issue. Command line push from Ubuntu VM. Works perfectly on my other repos under the same organization, syntax, and credentials. All repos have identical collaborators with write or admin permissions. It's quite confusing.

@sjlongland
Copy link

I have to add a "me too"… we have a CI server running Atlassian's Bamboo, and the user Bamboo is run under has its Docker credentials in ${HOME}/.docker/config.json:

{
	"auths": {
		"docker.io": {
			"auth": "…"
		},
		"https://registry-1.docker.io/v2/": {
			"auth": "…"
		}
	},
	"HttpHeaders": {
		"User-Agent": "Docker-Client/17.06.2-ce (linux)"
	}
}

We keep the credentials here because it saves us having to go and set them in each and every Docker task in each and every CI build/deployment job.

This, when it works, works fine. Then, mysteriously we see:

17-Sep-2017 01:35:17 | 31f9836d9272: Preparing
-- | --
17-Sep-2017 01:35:17 | a578965ebea2: Preparing
17-Sep-2017 01:35:17 | 340dd2d83760: Preparing
17-Sep-2017 01:35:17 | 03e4e87af7a2: Preparing
17-Sep-2017 01:35:17 | 9f8ebdc8fafb: Preparing
17-Sep-2017 01:35:17 | b92dd801d461: Preparing
17-Sep-2017 01:35:17 | 18f9b4e2e1bc: Preparing
17-Sep-2017 01:35:17 | db3ee8b8dcfd: Waiting
17-Sep-2017 01:35:17 | 31f9836d9272: Waiting
17-Sep-2017 01:35:17 | a578965ebea2: Waiting
17-Sep-2017 01:35:17 | 340dd2d83760: Waiting
17-Sep-2017 01:35:17 | 03e4e87af7a2: Waiting
17-Sep-2017 01:35:17 | 9f8ebdc8fafb: Waiting
17-Sep-2017 01:35:17 | b92dd801d461: Waiting
17-Sep-2017 01:35:17 | 18f9b4e2e1bc: Waiting
17-Sep-2017 01:35:19 | denied: requested access to the resource is denied

It has happened so frequently now… my short term fix is now muscle memory:

$ ssh root@ciserver
# sudo -sH ciuser
$ sed -ne '/"auth":/ { s/^.*: "\(.*\)"$/\1/; p }' .docker/config.json | head -n 1 | base64 -d | cut -f 2 -d:
…password printed here, I copy this to my clipboard…
$ docker login
Username: ${CI docker hub username}
Password: ${above password pasted back in}
$ exit
# exit

From that point, the password works… it's the same password, has not changed, did not change, all I've done is re-enter it into Docker, and Docker has stashed it in the same place as before. I'm a little miffed at this. It's not as though this is a token generated by the Docker Hub server that's then stashed… it's just the username and password, separated by a colon then mashed into a Base64 blob!

There's literally nothing to expire. We don't change the password on Docker hub, we don't change anything on the CI server.

Yet, mysteriously, this suddenly becomes the "wrong" password. We've had the problem for months, with literally no changes to our configuration. A few weeks back, I tried updating Docker just to see if that cured the bug, we now run:

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 267
Server Version: 17.06.2-ce
Storage Driver: aufs
 Root Dir: /srv/docker/aufs
 Backing Filesystem: xfs
 Dirs: 194
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 6e23458c129b551d5c9871e5174f6b1b7f6d1170
runc version: 810190ceaa507aa2727d7ae6f4790c76ec150bd2
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-93-generic
Operating System: Ubuntu 16.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 3.859GiB
Name: bneprdci0
ID: YZS7:QJT2:GBJ7:X36G:NL3R:C6XO:OPBS:PQ4L:Y2QW:LM2W:VBG5:G2DY
Docker Root Dir: /srv/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No swap limit support

No dice… we STILL get the problem… and I'm getting a little tired of my now every-few-daily ritual.

@Bharani77
Copy link

@baibhavvishal do you have a repo on docker hub? i had the same issue. You need to create a repo first which will be in the format of {username}/{project_name} and then you need to name your image the same way.

Hopefully that fixes your problem

my problem was caused by the host clock.
I fixed the host clock like sudo date -s "28 NOV 2013 hh:mm:ss" and retry it, and then, it was succeed.

@krivenok
Copy link

I've seen the same issue and it was also caused by the wrong time in my VM. The VM did not have automatic time sync with the host, so "docker push" worked fine right after boot (because time was correct) and stopped working after the pause/resume of the VM. It was not obvious to me why I got different results.

Unfortunately, docker does not perform the check before the upload of the image and fails after it has uploaded data. It was 4GB in my case. Logs also do not help.

@saiprasad2595
Copy link

@seanjensengrey
docker build -t seanjensengrey/test:foo .
docker push seanjensengrey/test:foo

This worked for me :) Thanks

@ryanvolum
Copy link

ryanvolum commented Jan 27, 2020

I'm also facing this issue, and like @phistakis and @nongdenchet it seems to be a product of the image size. I can build/push a small image without problem. I then try a larger image (~7GB), and after "pushing" everything, I then get unauthorized: authentication required.

If this is related to the image size, then the error message is wildly unhelpful. I wonder if, given the number of responses here that address the host machine's time as a potential culprit, the amount of time it takes to push the images is causing a conflict.

@zhiyi-zhang-duke
Copy link

zhiyi-zhang-duke commented Aug 19, 2020

In case anyone finds this thread, if you are using aks and pushing your image to your azure container registry. You will get the authentication error but it is NOT related to docker.
For me, all I had to do was login to my acr again:
az acr login --name acrName

@JozzX
Copy link

JozzX commented Oct 18, 2020

@baibhavvishal do you have a repo on docker hub? i had the same issue. You need to create a repo first which will be in the format of {username}/{project_name} and then you need to name your image the same way.
Hopefully that fixes your problem

my problem was caused by the host clock.
I fixed the host clock like sudo date -s "28 NOV 2013 hh:mm:ss" and retry it, and then, it was succeed.

Thank you.
My host clock was wrong because my CMOS battery was dead.
I replaced it, it solved the problem with Docker.

@sahanajoshi
Copy link

I'm also facing this issue, and like @phistakis and @nongdenchet it seems to be a product of the image size. I can build/push a small image without problem. I then try a larger image (~7GB), and after "pushing" everything, I then get unauthorized: authentication required.

If this is related to the image size, then the error message is wildly unhelpful. I wonder if, given the number of responses here that address the host machine's time as a potential culprit, the amount of time it takes to push the images is causing a conflict.

I am facing a similar issue. When I try to push a smaller image (120MB), it goes through perfectly. But when I try to push a larger image(400MB, which takes around 8-10 min on my LAN speed) , I get this message.

991d64e8c734: Layer already exists
45f0bd2aec3c: Pushing [==================================================>] 111.9MB
c2d7aa8dcec8: Layer already exists
4b54c5b6b908: Layer already exists
e255e51ee85e: Layer already exists
be141bdda2db: Layer already exists
56be7f20b594: Layer already exists
6e51be4e6460: Layer already exists
cffd05069f5d: Layer already exists
8b450189a4b2: Layer already exists
8362bdee65ae: Layer already exists
9ebafabc0ef6: Layer already exists
f63773c65620: Layer already exists
e6d60910d056: Pushing [==================================================>] 149.9MB
b52c1c103fae: Layer already exists
6f1c84e6ec59: Layer already exists
dd5242c2dc8a: Pushing [==================================================>] 119.2MB
unauthorized: authentication required

I'm certain I have logged in and have the privileges to push to the repo.

Docker version: Docker version 19.03.2, build 6a30dfc
Kernel information: Linux localhost.localdomain 3.10.0-1062.1.1.el7.x86_64 #1 SMP Fri Sep 13 22:55:44 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

I even tried some workarounds like having a parallel session issuing 'docker login' every 30s hoping to keep the session active, but no luck.

Any help is appreciated.

@bjornsnoen
Copy link

@sahanajoshi did you try fixing your system clock like some others have suggested? That did it for me, I was also able to push layers but once it got to the end it failed with authentication required. Probably caused by weird hibernation side effects. Fixed it with ntpdate and hwclock -w.

@rathodloki
Copy link

@baibhavvishal do you have a repo on docker hub? i had the same issue. You need to create a repo first which will be in the format of {username}/{project_name} and then you need to name your image the same way.
Hopefully that fixes your problem

my problem was caused by the host clock.
I fixed the host clock like sudo date -s "28 NOV 2013 hh:mm:ss" and retry it, and then, it was succeed.

Hostclock is messy,
Thankyou so much finally your solution works!

@kmabadshah
Copy link

enabling ntp worked for me

> timedatectl
.............
System clock synchronized: no
.............
> timedatectl set-ntp true
.............
Sysetm clock synchronized: yes
.............

@Ataa55
Copy link

Ataa55 commented Jul 2, 2024

i had the same issue while pulling some docker images, the problem was at my machine clock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests