• Post author:
  • Post category:Docker
  • Post last modified:May 9, 2024
  • Reading time:8 mins read

How to solve the Docker login error Error saving credentials: error storing credentials – err: exec: “docker-credential-desktop”: executable file not found in $PATH, out:” when trying to log in to the Docker hub or local container image library by using docker login -u command.

Advertisements
Error storing credentials - err: exec: “docker-credential-desktop”: executable file not found in $PATH, out:

This issue probably occurs if you install docker from CLI and don’t have docker desktop installed. By default, even CLI installation of Docker configures with docker desktop mode hence to make it work either you need to install docker desktop or remove the property from the config.

Solution 1: Replace or Remove credsStore from config.json file.

There are several ways to resolve this issue. One easiest way would be making any of the following changes in ~/.docker/config.json file.

  • Replace “credsStore” by “credStore” as many people suggest in other blogs.
  • Replace “credsStore” by any value.
  • Remove “credsStore” property from the config.

I would prefer using the last option which is deleting the credsStore entry from the file.

By default credsStore points to the desktop, this requires a docker desktop to be installed. When removing “s” or deleting property, docker will be in WSL and cannot locate credsStore property so they will use the default docker credential in Linux.

After removing an entry the file looks like below.

Now try to log in again and you should not see the Docker error Error saving credentials: error storing credentials – err: exec: “docker-credential-desktop”: executable file not found in $PATH, out:”

Error storing credentials - err: exec: “docker-credential-desktop”: executable file not found in $PATH, out:

For now, ignore the warning.

Note: On the internet, you pretty much find replace credsStore with credStore as a solution, however, the credStore is not a valid config key, so the only reason this works is because you are deleting the credStore entry. Hence, it’s better to just delete it so that it’s not misleading your config.

Solution 2: Remove the config file

Alternatively, take the backup of ~/.docker/config.json file and remove the original file. You can simply run the following command, this moves the file to a different name.


# Move the config to different name
mv ~/.docker/config.json ~/.docker/config.json_bkp

Now, run the command again and you should not see the error.

Solution 3: Install docker-credential-helper

You can also install docker-credential-helper to resolve error docker-credential-desktop executable file not found in $PATH. Since I am using MAC, I use brew install command as shown below.

docker-credential-helper is a generic tool provided by Docker to help manage and store authentication credentials securely for container registries. It is not specific to any particular operating system and can be used on various platforms, including macOS, Windows, and Linux. The purpose of this tool is to abstract the credential management process and provide a consistent way to store and retrieve credentials for Docker registries.


# Install docker-credential-helper
brew install docker-credential-helper

Note that while docker-credential-helper is a generic tool, each platform may have its own implementation of the helper tailored to its native credential management system. For instance, on macOS, the specific helper tool is docker-credential-osxkeychain, while on Windows, it’s docker-credential-wincred. On Linux, it’s docker-credential-secretservice.

I am using MAC hence, I will use docker-credential-osxkeychain to validate the installation.


# Check version
docker-credential-osxkeychain version

docker-credential-osxkeychain is a helper tool used by Docker on macOS to securely store and manage Docker credentials, such as authentication tokens or usernames and passwords, using the macOS Keychain. The Keychain is a password management system built into macOS that allows applications to securely store sensitive information like passwords, certificates, and private keys.

When you work with Docker, you often need to authenticate with container registries (like Docker Hub) to pull and push container images. These authentication credentials need to be securely stored, and that’s where docker-credential-osxkeychain comes into play.

If you are using Windows, use docker-credential-wincred. On Linux, use docker-credential-secretservice.

Finally, set credsStore to osxkeychain in ~/.docker/config.json


{
  "auths": {
    "https://index.docker.io/v1/": {}
  },
  "credsStore": "osxkeychain",
  "experimental": "enabled",
  "stackOrchestrator": "swarm"
}

Conclusion

In this article, you have learned different ways to solve Docker login error Error storing credentials – err: exec: “docker-credential-desktop”: executable file not found in $PATH, out:. For example, replace credsStore property with any value on ~/.docker/config.json file, remove the credsStore property, remove the complete JSON file, or install docker-credential-helper.

References