cli icon indicating copy to clipboard operation
cli copied to clipboard

Docker login to registry in windows server 2016 - Error saving credentials

Open RotemAmergi opened this issue 8 years ago • 19 comments

Hi ,

I am using windows server 2016 with docker for windows .

docker info Containers: 2 Running: 0 Paused: 0 Stopped: 2 Images: 105 Server Version: 18.06.0-ce Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: 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: d64c661f1d51c48782c9cec8fda7604785f93587 runc version: 69663f0bd4b60df09991c08812a60108003fa340 init version: fec3683 Security Options: seccomp Profile: default Kernel Version: 4.9.93-linuxkit-aufs Operating System: Docker for Windows OSType: linux Architecture: x86_64 CPUs: 2 Total Memory: 1.934GiB Name: linuxkit-00155d000400 ID: LDIE:JDCD:KNOR:RNPH:7MWV:MNKE:I2LH:3NMM:ZERH:M7HE:MWAI:Q4RW Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): true File Descriptors: 23 Goroutines: 48 System Time: 2018-08-02T14:33:25.5407319Z EventsListeners: 1 Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false

I am using jenkins pipeline for build docker images and it's build and tag the images but when i am trying to do docker login before push, i am getting this error :

"WARNING! Using --password via the CLI is insecure. Use --password-stdin. Error saving credentials: error storing credentials - err: exit status 1, out: A specified logon session does not exist. It may already have been terminated."

This is not happen to me when i am with logon active user .

Thanks ,

RotemAmergi avatar Aug 02 '18 14:08 RotemAmergi

Any update ?

RotemAmergi avatar Aug 06 '18 08:08 RotemAmergi

Any update ?

RotemAmergi avatar Aug 12 '18 15:08 RotemAmergi

I'm getting the same error... can't find a response. Help!

deevodavis71 avatar Sep 05 '18 14:09 deevodavis71

Any update ?

RotemAmergi avatar Sep 13 '18 06:09 RotemAmergi

Jumping on the bandwagon here... same issue, using docker plugin and jenkinsfile: stage('Dockerfile Push') { pipelineParams['registries'].each { reg -> echo "Pushing to registry: ${reg['name']}" docker.withRegistry("https://${reg['name']}", reg['credentialsId']) {

Error happens on the last line of above:

$ docker login -u ******** -p ******** https://dockerinternal.sanitized.com WARNING! Using --password via the CLI is insecure. Use --password-stdin. Error saving credentials: error storing credentials - err: exit status 1, out: A specified logon session does not exist. It may already have been terminated.

mrysanek avatar Sep 17 '18 15:09 mrysanek

Followup: This only happens through an ssh session to the Windows server. When the same command is run locally, the login succeeds. When an ssh session is established directly to the server (NOT using Jenkins) the same error is observed.

mrysanek avatar Sep 17 '18 16:09 mrysanek

Digging into the server's event log I got this:

System.ComponentModel.Win32Exception (0x80004005): Failed to write credentials at Microsoft.Alm.Authentication.BaseSecureStore.WriteCredential(String targetName, Credential credentials) at Microsoft.Alm.Authentication.SecretStore.WriteCredentials(TargetUri targetUri, Credential credentials) at Microsoft.Alm.Cli.Program.Store() at Microsoft.Alm.Cli.Program.Run(String[] args)

Log Name: Application Source: Git Credential Manager Date: 9/17/2018 10:49:33 AM Event ID: 0 Task Category: None Level: Error Keywords: Classic User: N/A Computer: ******.com

I am using OpenSSH running on the server, and found a similar problem (albeit with a git push for client rather than docker login):

https://github.com/Microsoft/Git-Credential-Manager-for-Windows/issues/502

My issue is, in fact, the user and owner are different when I run this from a powershell launched through the ssh session: [Security.Principal.WindowsIdentity]::GetCurrent() This is the reason Jenkins pipeline docker usage fails for me (beause it's connected through an ssh session). When the above is run in a powershell spawned through an RDP session, the user and owner are the same.

@RotemEmergi @deevodavis71 Either of you using same access method to the Windows server (OpenSSH)?

mrysanek avatar Sep 17 '18 16:09 mrysanek

I am using with ssh

RotemAmergi avatar Sep 17 '18 17:09 RotemAmergi

Hey Guys,

I have had the same issue, when trying to authenticate from a PowerShell session, while it was working fine when the same command was executed locally.

The way I have fixed it, is by looking at the C:\Users_youruser_.docker\config.json If there is a line like: "credsStore": "wincred" , make sure that you change it to the following: "credsStore": "", save the config, and re-execute the same command locally: $ docker login -u ******** -p ******** url

Afterwards take a look at the config again, and now you should have the following line instead, under the repository: "auth": "...."

Having the config that way, allowed me to execute successfully the commands from another session as well.

DankoValkov avatar Feb 11 '19 09:02 DankoValkov

I have the same problem, except it doesn't seem to have anything to do with SSH. Docker CLI will sometimes just start doing giving me this error when trying to log into an AWS ECR repository that has worked previously. The only thing I can find that makes it come right again (for a while) is to reinstall Docker. It's really annoying. I tried deleting the credentials that Docker stores in Windows Credentials Manager but that doesn't seem to help at all.

samjgalbraith avatar Feb 28 '19 20:02 samjgalbraith

Changing the credentials that are stored in "Windows Credentials Manager" wasn't helpful for my case as well, that's why I had to change the config file of the Docker directly on that environment.

After making sure that the password written in the login command matches the one inside the config, under the "auth": "yy==" like: docker login -u ******** -p yy== url resolved the issue for me, and I was able to both execute the command successfully on prem, and remotely as well.

DankoValkov avatar Mar 01 '19 08:03 DankoValkov

Having the issue while executing via ssh.

basilin avatar Feb 04 '20 12:02 basilin

EDIT: The workaround doesn't work anymore. Docker always overwrites now the credsStore when it's empty.

~~The workaround of setting credsStore to "" works however in the latest version of Docker (2.2.0) when you restart Docker it will reset that field to desktop failing again...~~

~~For my case this workaround is not useful since every time we reboot the build machine we will need to log in and manually change that value or write some kind of script and put it everywhere in our pipeline.~~

~~My workaround for the workaround is to create a separate .config.json file with the property empty in a non-default location and run all the Docker commands pointing to that config file so it will use it but it won't find it to reset the value on restart.~~

pleonex avatar Feb 07 '20 07:02 pleonex

Hi all I have this exact issue on Windows 10 I:

  1. Can see the credential in the windows credential manager
  2. Have tried clearing that credential and logging back in again
  3. Have checked windows event viewer with nothing of note
  4. Have tried clearing out docker.config's entry for credsStore
  5. Have checked that Network access: Do not allow storage of passwords and credentials for network authentication is disabled

Has anyone found a resolution for this issue it is driving me crazy

owlyowl avatar Aug 17 '20 21:08 owlyowl

Same exact thing for me. Tried all the fixes.

FYI I am using TeamCity to fire off a Powershell Script on that server and it fails the build, but when I go to the server and manually run it, it works fine. It's also sporadic. Works fine some builds, then magically one day it doesn't work.

jredp avatar Aug 31 '20 19:08 jredp

For what it's worth, the method of removing "wincred" worked for me.

mikemorton avatar May 12 '21 17:05 mikemorton

any updates on this? Having this issue when trying to login via ssh (using ansible)

sbudaraj-vcc avatar Sep 22 '21 13:09 sbudaraj-vcc

I hit the same problem using OpenSSH (via PowerShell Start-Process Cmdlet) to connect to a Windows Server 2019 from PowerShell and execute docker login if wincred credential helper is configured in ~/.docker/config.json. Not sure if the culprit is ssh.exe, docker.exe or wincred.exe.

I use ssh.exe to invoke 'docker login' and it works fine if storing base64-encoded plain text credentials in ~/.docker/config.json. On the other hand, if I want to use wincred credential helper, docker login fails when invoked through ssh.exe from OpenSSH (via PowerShell Start-Process Cmdlet) with: Error saving credentials: error storing credentials - err: exit status 1, out: A specified logon session does not exist. It may already have been terminated.

$ ssh -V OpenSSH_for_Windows_8.6p1, LibreSSL 3.3.3

$ docker -v Docker version 20.10.9, build 591094d

xorcus avatar Mar 29 '22 19:03 xorcus

+1 to the above "workaround" / UX issues. My credsStore was set to docker desktop. Changing it to "" and then running docker login seems to have worked.

peabnuts123 avatar Apr 09 '22 20:04 peabnuts123