Photo by Chris Ried on Unsplash
So there I was, midnight deploy, everything's going fine — and then Docker just decides to ruin my evening with this gem:
Error saving credentials: error storing credentials - err: exit status 1,
out: `error getting credentials - err: exit status 1,
out: `No such file or directory``
Or sometimes it shows up as:
docker: Error response from daemon: unauthorized: authentication required.
The docker error getting credentials problem is one of those things that hits you out of nowhere — usually right when you're trying to push an image to Docker Hub or pull from a private registry. I've seen this pop up on fresh Linux installs, WSL2 setups, and even on machines that were working perfectly fine the day before. It's maddening.
Here's what's actually happening: Docker uses a credential helper to securely store your login info. When that helper is either missing, misconfigured, or just pointing to something that doesn't exist on your system, Docker throws up its hands and refuses to authenticate. The config file is the usual culprit — specifically ~/.docker/config.json.
Let me walk you through the fixes that have actually worked for me and my team.
First, Look at What Your Config Says
Before touching anything, open up your Docker config file:
cat ~/.docker/config.json
You'll probably see something like this:
{
"credsStore": "desktop",
"auths": {}
}
That "credsStore": "desktop" line is telling Docker to use the Docker Desktop credential store. If you're on a Linux machine or WSL2 without Docker Desktop running properly, that store doesn't exist — and boom, you get the error. On some setups it says "credsStore": "secretservice" or "credsStore": "osxkeychain" which can also cause issues depending on your environment.
Fix 1: Remove or Clear the credsStore Entry
Honestly, this is the fix that works 80% of the time. Just edit your config file and remove the credsStore line, or replace the whole thing with a clean config:
nano ~/.docker/config.json
Replace the contents with:
{
"auths": {}
}
Save it, then log back into Docker Hub (or your private registry):
docker login
This time it'll store the credentials directly in the config file as a base64-encoded string instead of trying to hand them off to a helper that doesn't exist. Not the most secure approach for production environments, but for a dev machine or a CI/CD pipeline? It works great.
Fix 2: Install the Right Credential Helper
If you want to do this properly — and honestly, for anything beyond a personal dev box you should — you need to make sure the correct credential helper is installed and accessible.
On Ubuntu/Debian systems, install pass and docker-credential-pass:
sudo apt-get install pass
wget https://github.com/docker/docker-credential-helpers/releases/download/v0.7.0/docker-credential-pass-v0.7.0.linux-amd64
chmod +x docker-credential-pass-v0.7.0.linux-amd64
sudo mv docker-credential-pass-v0.7.0.linux-amd64 /usr/local/bin/docker-credential-pass
Then update your ~/.docker/config.json to point to it:
{
"credsStore": "pass"
}
You'll also need to initialize pass with a GPG key if you haven't already — that's a whole mini-rabbit-hole but the short version is:
gpg --gen-key
pass init your-gpg-key-id
A little more setup upfront, but this is the clean, secure way to handle it. On macOS the credential helper is osxkeychain and it usually works out of the box, so if you're seeing this error on a Mac, jump straight to Fix 1 and check if something corrupted your config.
Fix 3: The WSL2-Specific Headache
If you're running Docker on Windows with WSL2 and getting this error, there's a slightly different thing going on. Docker Desktop handles credentials through its own Windows-side store, and sometimes the integration between WSL and the Windows credential manager just... breaks. I've seen this happen after a Docker Desktop update especially.
First, make sure Docker Desktop is actually running on the Windows side — not just sitting in the system tray crashed. Then inside your WSL terminal, try:
docker logout
docker login
If that doesn't work, check if the credential helper binary is visible from inside WSL:
which docker-credential-desktop
If you get nothing back, Docker Desktop hasn't set up the PATH correctly in your WSL distro. You can fix this by adding the Docker Desktop bin folder to your WSL PATH in ~/.bashrc or ~/.zshrc:
export PATH="$PATH:/mnt/c/Program Files/Docker/Docker/resources/bin"
Restart your terminal and try logging in again. This one trips people up because the error message gives you zero indication that it's a PATH issue.
Fallback: Nuke and Restart the Docker Config
When nothing else works — and sometimes nothing else works — just back up and delete the entire Docker config directory and start fresh:
mv ~/.docker ~/.docker.backup
docker login
Docker will recreate the config directory on login. I've had situations where the config file got partially corrupted (especially after a crash mid-write) and this was the only thing that fixed it. Keep the backup around for a day just in case you had other settings in there like registry mirrors or proxy configs.
One last thing — if you're running into the docker error response from daemon: unauthorized variant specifically with a private registry, double-check that you're logging into the right registry URL. A lot of people run docker login and assume it hits their private registry, but it defaults to Docker Hub. You need to be explicit:
docker login your-registry.example.com
Hope this saves you the hour I lost the first time I ran into this. The fix is almost always in that config file — once you know where to look, it's a five-minute problem.
๋๊ธ
๋๊ธ ์ฐ๊ธฐ