Solving "docker-credential-desktop.exe: executable file not found in $PATH" Error
When working with Docker, you might encounter the error message: exec: "docker-credential-desktop.exe": executable file not found in $PATH
. This error typically occurs during operations like docker build
where Docker attempts to authenticate with a registry but cannot find the credential helper binary.
Understanding the Root Cause
The error stems from Docker's credential management system. When your Docker configuration file contains a credsStore
property, Docker tries to use an external binary (docker-credential-<value>
) to handle authentication credentials. If this binary isn't available in your system's PATH, the operation fails.
Common Scenarios
This issue commonly occurs when:
- Switching between Docker installations (Docker Desktop vs. Docker Engine)
- Using WSL2 with Docker Desktop on Windows
- Migrating from Docker Desktop to alternatives like Colima or Rancher Desktop
- After Docker Desktop updates or reinstallations
Primary Solutions
Method 1: Edit Docker Configuration File
The most reliable fix is to modify your Docker configuration to either remove or rename the problematic credential store setting.
- Open your Docker configuration file:
nano ~/.docker/config.json
- Look for the
credsStore
property and either:- Delete the entire line containing
"credsStore": "desktop"
- OR rename it to
"credStore": "desktop"
- Delete the entire line containing
Example before modification:
{
"credsStore": "desktop",
"auths": {}
}
Example after modification:
{
"credStore": "desktop",
"auths": {}
}
- Save the file and try your Docker command again.
Windows Users
If you're using Windows with WSL2, you might have two Docker configuration files:
~/.docker/config.json
(WSL environment)C:\Users\<username>\.docker\config.json
(Windows host environment)
Make sure to update both if needed.
Method 2: Remove Docker Configuration Directory
If you don't have important Docker configurations to preserve, you can remove the entire Docker configuration directory:
rm -rf ~/.docker
This will reset all Docker configurations to defaults. Docker will recreate the directory with default settings when you next run a Docker command.
Data Loss Warning
This approach will remove all your Docker configurations, including registry credentials and custom settings. Only use this if you're comfortable with resetting everything.
Platform-Specific Solutions
For macOS Users
If you have Docker Desktop installed but still encounter the issue:
- Ensure Docker CLI is in your PATH:
echo 'export PATH="/Applications/Docker.app/Contents/Resources/bin:$PATH"' >> ~/.zshrc
# For bash users: use ~/.bash_profile instead of ~/.zshrc
- Reload your shell configuration:
source ~/.zshrc
- Verify Docker is accessible:
which docker
- Alternatively, install the credential helper:
brew install docker-credential-helper
For Windows Users
Try PowerShell: Some users report that using PowerShell instead of Command Prompt resolves the issue.
Update Docker Desktop: Check for and install any available updates to Docker Desktop.
Ensure WSL is running: If using WSL2, make sure your WSL environment is properly started before running Docker commands.
For Linux Users (Non-Docker Desktop)
If you're using Docker Engine without Docker Desktop:
- Edit the configuration file as described in Method 1
- Alternatively, install Docker Desktop if you need the credential helper functionality
Explanation: Why This Works
The credsStore
property in Docker's configuration specifies an external credential helper binary. When set, Docker attempts to store and retrieve credentials using docker-credential-<value>
(where <value>
is the string specified in credsStore
).
By removing or modifying this setting, you're telling Docker to:
- Either use a different credential helper (if you rename
credsStore
tocredStore
) - Or fall back to storing credentials directly in the config file's
auths
property (if you remove the line entirely)
This approach eliminates the dependency on the missing docker-credential-desktop.exe
binary.
Verification
After applying any of these solutions, verify that Docker commands work correctly:
docker pull ubuntu:18.04
docker build .
The error should no longer appear, and your Docker operations should proceed normally.
When to Seek Additional Help
If none of these solutions work, consider:
- Checking Docker installation: Ensure Docker is properly installed and running
- Reviewing system PATH: Verify that Docker binaries are included in your system's PATH
- Checking file permissions: Ensure you have appropriate permissions for Docker operations
- Consulting Docker documentation: Review the official Docker credential store documentation
Most users find that modifying the ~/.docker/config.json
file resolves this issue permanently, allowing them to continue using Docker without credential-related errors.