docker login fails with 'error storing credentials' on Linux
Error saving credentials: error storing credentialsShort answer
Docker hands your password to a credential helper named in ~/.docker/config.json. The error means that helper is missing, not on PATH, or not set up (pass has no GPG key). Look at config.json first, then install the helper, initialise pass, or remove the stale credsStore line.
Fix it fast
1Find out which cause you have
Read the Docker client config. The credsStore or credHelpers entry names the helper that is failing.
cat ~/.docker/config.json which docker-credential-desktop docker-credential-pass docker-credential-secretservice2Match what you see, then jump to its fix
- 1
config.json has a credsStore value, and which prints nothing for docker-credential-<value>The helper named in config.json is not installed or not on PATHFix - 2
credsStore is pass and docker-credential-pass exists, yet login still failsThe helper is pass, but pass has no GPG key behind itFix - 3
You do not want a keychain on a server or CI boxThe login is stored in plain text by choiceFix
- 1
What does the error look like?
Error saving credentials: error storing credentialserror getting credentials - err: exit status 1
Cause 1 of 3
The helper named in config.json is not installed or not on PATH
1Check
The value of credsStore is the part after docker-credential-. Docker looks for that binary on PATH. If the named binary is not installed, the login cannot be stored.
grep -E 'credsStore|credHelpers' ~/.docker/config.json
command -v docker-credential-desktop2Fix
Install the helper you want from the docker-credential-helpers releases, or delete the credsStore line so Docker stores the login in config.json. Run docker logout first so nothing stays in the old place.
docker logout
# edit ~/.docker/config.json and remove the "credsStore" line
docker login3Verify
docker login prints Login Succeeded.
docker loginConfirmed by docs.docker.com
Cause 2 of 3
The helper is pass, but pass has no GPG key behind it
1Check
The pass helper stores secrets in a GPG-encrypted password store. The store must be initialised with a key ID from the gpg2 keyring.
gpg --list-keys
ls ~/.password-store2Fix
Create a key, take the ID from the pub line, and initialise pass with it.
gpg --generate-key
pass init <your-gpg-id>3Verify
Log in again. You may be asked for the passphrase you set for the key.
docker loginConfirmed by docs.docker.com
Cause 3 of 3
The login is stored in plain text by choice
1Check
With no credsStore and no credHelpers, Docker writes the login into config.json as base64 text. That is less safe than a store, but it is what Docker does when none is set.
grep -A3 '"auths"' ~/.docker/config.json2Fix
Remove credsStore, log in once, and keep the file readable only by the user. For CI, use a short-lived or scoped access token instead of a password.
chmod 600 ~/.docker/config.json
docker login3Verify
The registry host appears under auths and pulls from private repositories work.
docker pull <your-private-image>Confirmed by docs.docker.com
How do I stop it coming back?
- Do not copy ~/.docker/config.json between machines; it carries the helper name with it.
- Run docker logout before you change credsStore, so no credential is left in the old store.
- On servers, use an access token with the least scope the job needs.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fixServers
sam local fails: Running AWS SAM projects locally requires Docker
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
sam local start-api and sam local invoke run your function inside a Docker container, so SAM stops if it cannot talk to Docker.
3 causes, each with a fixServers
dnf fails to download repo metadata in a CentOS 8 Docker build
The same Dockerfile built fine before 2022
CentOS Linux 8 reached end of life on 31 December 2021 and its content left the mirrors.
2 causes, each with a fixServers
pip install confluent-kafka fails because librdkafka/rdkafka.h is missing
pip stops while building confluent-kafka from source
The error means pip is compiling confluent-kafka from source, and the compiler cannot find the librdkafka C headers.
3 causes, each with a fixServers
Cypress says the npm package is installed but the binary is missing
Cypress binary is missing after npm install in CI or in a Docker build
The npm package is only a launcher.
3 causes, each with a fixServers
A dev container port does not open in the browser when Docker runs on a remote host
If your application only accepts calls from localhost, it will reject connections from published ports
Three things usually break it: the app listens only on localhost inside the container, so published ports are rejected; you open the container port instead of the mapped localhost port VS Code shows; or you changed appPort or a Compose ports list and did not rebuild.
3 causes, each with a fix