Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker login: error storing credentials `The stub received bad data.`

First, I installed AWS-CLI and I already used "AWS configure" to set up my secret key and I also used "Docker login" command to log in and I got success and when I typed Get-ECRLoginCommand. It works and returns the result for me.

But when I try to use the command :

(Get-ECRLoginCommand).Password | docker login --username AWS --password-stdin 837859123533.dkr.ecr.ap-east-1.amazonaws.com/spring-boot

I got an error that looks like this:

Error saving credentials: error storing credentials - err: exit status 1, out: error storing credentials - err: exit status 1, out:The stub received bad data.``

like image 449
PangSoramDepo Avatar asked Mar 23 '20 03:03

PangSoramDepo


4 Answers

Edit: Also see Ethan Davis's solution:

I found that removing C:\Program Files\Docker\Docker\resources\bin\docker-credential-desktop.exe and C:\Program Files\Docker\Docker\resources\bin\docker-credential-wincred.exe worked for me. – Ethan Davis Sep 29 '20 at 18:10


Original: The solution linked by Joelster's comment worked for me.

One quick workaround is to modify .docker\config.json file. Remove the following line so docker will use file system to store tokens:

          "credsStore": "wincred"

I opened the file c:\Users\sashoalm\.docker\config.json, and I deleted the "credsStore" key. After that this worked:

type pass.txt | docker login -u AWS --password-stdin https://123123.dkr.ecr.us-west-1.amazonaws.com

And the output was this:

WARNING! Your password will be stored unencrypted in C:\Users\sashoalm\.docker\config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
like image 167
sashoalm Avatar answered Nov 09 '22 23:11

sashoalm


As of today's date, this issue still persists. Below are the things I discovered-

1.) This problem shows up while using SSOs for authentication. I am using Azure SSO for AWS.(https://www.npmjs.com/package/aws-azure-login)

2.) The reason is- The token returned from SSOs is long enough(more than 2550 characters) where as windows credential manager does not support such long tokens.

3.) If you use ECR credential helper (https://github.com/awslabs/amazon-ecr-credential-helper), sadly it also does not seem to work with SSOs- https://github.com/awslabs/amazon-ecr-credential-helper/issues/229

However, I followed these steps as a workaround & I'm on Windows-

1.) Remove/Rename the "docker-credential-wincred.exe" file located in "C:\Program Files\Docker\Docker\resources\bin" directory.

2.) Remove the "credStore" & "credsStore" keys from the docker config(C:\Users\PROFILE_NAME\.docker\config.json).

I get the following response-

WARNING! Your password will be stored unencrypted in C:\Users\sandeep.kumar\.docker\config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
  • Tickets opened to address this issue-

https://github.com/danieljoos/wincred/issues/18

https://github.com/aws/aws-cli/issues/5636

like image 7
Sandeep Avatar answered Nov 09 '22 22:11

Sandeep


Both solutions worked for me, delete file C: \ Program Files \ Docker \ Docker \ resources \ bin \ docker-credential-desktop.exe and C: \ Program Files \ Docker \ Docker \ resources \ bin \ docker-credential-wincred. exe and delete {"credsStore": "...."} then my structure is as follows in the config.json file

{
  "auths": {
     "Account_AWS.dkr.ecr.Region_AWS.amazonaws.com": {
         "auth": "My token"
     }
  },
  "HttpHeaders": {
    "User-Agent": "Docker-Client / 19.03.13 (windows)"
  },
  "stackOrchestrator": "swarm"
}
like image 2
JuanSe Silva Avatar answered Nov 09 '22 22:11

JuanSe Silva


As @Ethan Davis mentioned, removing the following files helped me:

  • C:\Program Files\Docker\Docker\resources\bin\docker-credential-desktop.exe
  • C:\Program Files\Docker\Docker\resources\bin\docker-credential-wincred.exe
like image 2
Rene B. Avatar answered Nov 09 '22 21:11

Rene B.