Skip to content

Docker Login Credentials Error: Error storing credentials

Problem

When attempting to log in to Docker using docker login, you may encounter an error similar to:

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/``

This error typically occurs due to issues with Docker's credential storage system, particularly with the GPG-based password store on Linux systems or credential helper configuration on various platforms.

Common Causes

  • Corrupted or misconfigured Docker credential storage
  • Permission issues with the .docker directory or GPG keys
  • Missing or incorrect credential helper configuration
  • GPG key passphrase issues
  • Outdated or corrupted Docker configuration files

Solutions

1. Remove Corrupted Docker Configuration

The most common solution involves removing the corrupted Docker configuration file:

bash
# Stop Docker service
sudo service docker stop

# Remove the configuration file
rm ~/.docker/config.json

# Restart Docker service
sudo service docker start

After restarting, try logging in again with docker login.

WARNING

This will remove all Docker registry credentials, so you'll need to re-authenticate with all your registries.

2. Fix File Permissions

If permission issues are causing the error, adjust ownership of the .docker directory:

bash
sudo chown -R $(id -u):$(id -g) $HOME/.docker

3. Configure Docker Credential Helper (Linux)

For Linux systems using Docker Desktop, you may need to properly configure the credential helper:

bash
# Generate a GPG key (follow the prompts)
gpg --generate-key

# Initialize pass with the generated GPG key ID
pass init <generated-gpg-key-id>

The GPG key ID can be found in the output of the generate command (look for the line starting with "pub").

4. Remove Problematic Credential Helpers

Clear out the existing credential helpers that might be causing issues:

bash
# Remove docker credential helpers from password store
rm -rf ~/.password-store/docker-credential-helpers

Alternatively, you can use the pass command if available:

bash
pass remove -rf docker-credential-helpers

5. Fix Credential Store Configuration

Edit your Docker configuration to ensure the credential store is properly configured:

bash
nano ~/.docker/config.json

Check the credsStore field. Common values include:

  • osxkeychain (macOS)
  • wincred (Windows)
  • pass (Linux with GPG)

Ensure the value matches your operating system and Docker installation.

TIP

On some systems, changing credsStore to credStore (without the "s") has resolved the issue.

6. Windows-Specific Solutions

For Windows users:

  1. Remove problematic credential helper executables from C:\Program Files\Docker\Docker\resources\bin\:

    • docker-credential-desktop.exe
    • docker-credential-wincred.exe
  2. Or ensure the credsStore field in ~/.docker/config.json is correctly set to wincred.

7. Use Personal Access Token Instead of Password

If you continue to experience issues, try using a Personal Access Token (PAT) from Docker Hub instead of your password:

  1. Generate a PAT in your Docker Hub account settings
  2. Use the token as your password when running docker login

8. Check for GPG Key Passphrase Issues

If you set a passphrase for your GPG key, it might interfere with Docker's credential helper. You can remove the passphrase:

bash
# List your GPG keys
gpg --list-keys

# Edit the key to remove passphrase
gpg --edit-key <your-key-id>
# At the gpg prompt, enter: passwd
# Enter current passphrase, then leave new passphrase blank
# Confirm you want no protection

Security Note

Removing passphrase protection from your GPG key reduces security. Only do this if necessary and understand the risks.

9. Comprehensive Fix for Persistent Issues

If the above solutions don't work, try this comprehensive approach:

bash
# Stop Docker
service docker stop

# Remove config and credential helpers
rm ~/.docker/config.json
rm -rf ~/.password-store/docker-credential-helpers

# Generate new GPG key
gpg --generate-key

# Initialize pass with new key
pass init <new-gpg-key-id>

# Restart Docker
service docker start

Prevention

To avoid this issue in the future:

  1. Ensure you complete the credential management setup during Docker installation
  2. Regularly update Docker to the latest version
  3. Avoid manually editing the config.json file unless necessary
  4. Use Personal Access Tokens instead of passwords when possible

When to Seek Further Help

If none of these solutions work, consider:

  1. Checking Docker's official documentation for credential management
  2. Looking for issues specific to your Docker version and OS combination
  3. Consulting Docker community forums or GitHub issue trackers

INFO

Docker credential management varies significantly between operating systems. Always check the official Docker documentation for your specific platform.