47

I have Ubuntu 20.04 and I have tried using docker login to log in in terminal, but got:

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: sfelshtyn
Password: 
Error saving credentials: error storing credentials - err: exit status 1, out: `error getting credentials - err: exit status 1, out:` no usernames for https://index.docker.io/v1/``
Tiago Martins Peres
  • 14,289
  • 18
  • 86
  • 145
Stanislav Felshtyn
  • 761
  • 1
  • 5
  • 8
  • 2
    Solution: I did a few steps: (You can find here: https://docs.docker.com/desktop/linux/) gpg --generate-key ... – Stanislav Felshtyn Apr 07 '22 at 14:33
  • 10
    This ended up fixing it for me. I did have to first do `rm -rf ~/.password-store/docker-credential-helpers` to reset things and get it to work. – tayden Jul 18 '22 at 16:30
  • @StanislavFelshtyn I suggest that you put this as an answer. – Aram Hovhannisyan Aug 04 '22 at 06:11
  • 4
    Execute `gpg --generate-key` and then `pass init ""` and then `docker login` should work. This at least works for me on Ubuntu 22.04. – Ini Aug 24 '22 at 16:29
  • I installed docker using the desktop app installation, after removing it and installing via `apt` everything worked. – ניר Aug 23 '23 at 08:56

11 Answers11

64

Try to execute following command

service docker stop
rm ~/.docker/config.json
service docker start

then try docker login it will ask for username and password

Tanjin Alam
  • 1,728
  • 13
  • 15
  • [Related comment in a GH issue for reference](https://github.com/docker/docker-credential-helpers/issues/140#issuecomment-1149610603) – ggorlen Jun 14 '23 at 14:15
29

I read Error saving credentials: error storing credentials - err: exit status 1, out: pass store is uninitialized to solve my problem, but none of them helped.

Then I switched to official docker documentation and found that I didn't go through the credentials management process during docker installation.

I did a few steps:

  1. gpg --generate-key
  2. pass init <generated gpg-id public key>
  3. docker pull molly/privateimage

After that I tried again docker login. I passed my personal data and it worked for me. I solved my issue.

Tiago Martins Peres
  • 14,289
  • 18
  • 86
  • 145
Stanislav Felshtyn
  • 761
  • 1
  • 5
  • 8
  • Thanks! Definitely the answer that fixed my issue in the most proper way. This wasn't necessary on macos but is on linux – xdzzz Jan 01 '23 at 01:38
12

This worked for me -

pass remove -rf docker-credential-helpers
Hrishikesh Kadam
  • 35,376
  • 3
  • 26
  • 36
7

The following helped me:

  1. rm -rf ~/.password-store/docker-credential-helpers
  2. gpg --generate-key
  3. pass init <generated gpg-id public key>
7
  1. Remove the key credStore from ~/.docker/config.json, and everything works normal now.

    Before:

     {
         "auths": {},
         "credsStore": "desktop", // remove this line, irrespective of the value of credStore
         "currentContext": "desktop-linux"
     }
    

    After:

     {
         "auths": {},
         "currentContext": "desktop-linux"
     }
    
  2. Remove docker-credential-helpers

    rm -rf ~/.password-store/docker-credential-helpers
    
  3. Generate GPG Key Pair

    gpg --generate-key
    
  4. Initialize pass utility, which is a password manager that uses GPG encryption for storing and managing passwords

    pass init <generated gpg-id public key>
    

References:

  1. https://github.com/docker/docker-credential-helpers/issues/24#issuecomment-595692091
  2. https://github.com/docker/docker-credential-helpers/issues/60#issuecomment-336748027
Vishal Kumar
  • 403
  • 4
  • 13
3

I fixed it as below for windows machine,

  1. Go to your C://Users/YOUR_USER_FOLDER

  2. Get inside .docker folder

  3. Remove config.json file

  4. Try login again and it succeeded.

micronyks
  • 54,797
  • 15
  • 112
  • 146
3

Just to add another solution taking from the other answers here.

If you've already started Docker Desktop and you're seeing the error:

error storing credentials - err: exit status 1, out: `error getting credentials - err: exit status 1

Stop the application:

systemctl --user stop docker-desktop

If you've already followed the steps in credentials-management-for-linux-users , delete the existing pass key:

rm -rf ~/.password-store/docker-credential-helpers

Generate a new key and provide the correct credentials:

gpg --generate-key

Note: make sure you set the correct email in the passkey you use to login into DockerHub. I used the wrong one, which was why Docker Desktop threw the error.

This will print out text like:

pub   rsa3072 2023-06-13 [SC] [expires: 2025-06-12]
      9F53995439D023FD
uid                      Your Name <Your Email>
sub   rsa3072 2023-06-13 [E] [expires: 2025-06-12]

Then use the gpd-id displayed within the pub section to initialise pass, e.g.:

pass init 9F53995439D023FD

Finally, start Docker Desktop:

systemctl --user start docker-desktop 

Hope this helps!


UPDATE: I also ran into problems logging into AWS ECR on Ubuntu with the error:

Error saving credentials: error storing credentials - err: exit status 1, out: `error storing credentials - err: exit status 1, out: `exit status 1: gpg: public key of ultimately trusted key 9F53995439D023FD not found
gpg: public key of ultimately trusted key 7F525559F4750A05 not found
gpg: public key of ultimately trusted key 3D39C9F57C3C2E11 not found
gpg: public key of ultimately trusted key DCB9A14562B73138 not found
gpg: public key of ultimately trusted key 91B3075B62503284 not found
Password encryption aborted.``

I was able to fix the issue and login to ECR by following the steps in this gist. I'll reproduce them below in case the gist is deleted in the future:

#!/bin/bash

gpg --check-trustdb 2>&1| grep 'not found' | awk '{print $8}' >bad-keys.txt
gpg --export-ownertrust > ownertrust-gpg.txt
mv ~/.gnupg/trustdb.gpg ~/.gnupg/trustdb.gpg-broken
for KEY in `cat bad-keys.txt` ; do sed -i "/$KEY/d" ownertrust-gpg.txt ; done
gpg --import-ownertrust ownertrust-gpg.txt
rm bad-keys.txt ownertrust-gpg.txt
Greg Brown
  • 1,251
  • 1
  • 15
  • 32
2

It's worked for me

service docker stop
rm ~/.docker/config.json
rm /usr/local/bin/docker-credential-pass
service docker start

Basically, you need to remove your credentials from your local environment,(These two rm ~ commands do this work)

If you are having permission issues, use sudo

Jahidul
  • 334
  • 1
  • 6
2

After trying all of the above method, the issue still persists, use your email id to login rather than your username

binrebin
  • 357
  • 4
  • 16
0

When you run the gpg command. Then while running the pass init command, pass the pub key generated on the the output of gpg command.

$ pass init <pub key from gpg command>

0

I changed the value of "credsStore" to "wincred" in config.json and I was able to login with my windows credential

Sunil Kumar
  • 152
  • 1
  • 1
  • 12