81

I might have a bit of a messed Docker installation on my Mac.. At first I installed Docker desktop but then running it I learned that as I'm on an older Mac I had to install VirtualBox so I did following these steps:

  1. enable writing on the /usr/local/bin folder for user

    sudo chown -R $(whoami) /usr/local/bin

  2. install Docker-Machine

base=https://github.com/docker/machine/releases/download/v0.16.0 &&
  curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/usr/local/bin/docker-machine &&
  chmod +x /usr/local/bin/docker-machine
  1. install Xcode CLI..manually from dev account

  2. Install Home Brew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. Install Docker + wget ( Using Brew)

    brew install docker

    brew install wget

  2. Install bash completion scripts

base=https://raw.githubusercontent.com/docker/machine/v0.16.0
for i in docker-machine-prompt.bash docker-machine-wrapper.bash docker-machine.bash
do
    sudo wget "$base/contrib/completion/bash/${i}" -P /etc/bash_completion.d
done
  1. enable the docker-machine shell prompt

    echo 'PS1='[\u@\h \W$(__docker_machine_ps1)]\$ '' >> ~/.bashrc

  2. Install VirtualBox, ExtensionPack and SDK: https://www.virtualbox.org/wiki/Downloads

I now installed docker-compose (docker-compose version 1.29.2, build unknown) with home-brew but when running docker-compose up I get the following error:

docker.credentials.errors.InitializationError: docker-credential-desktop not installed or not available in PATH

which docker prints /usr/local/bin/docker.

Brew installations are in /usr/local/Cellar/docker/20.10.6 and /usr/local/Cellar/docker-compose/1.29.2. As I see there is also a home-brew for docker-machine should I install docker-machine via home-brew instead?

What can I check to make sure that I use the docker installations from home-brew and wipe/correct the installations made from steps above?

5
  • 1
    Can you try this solution?
    – Nick ODell
    May 21, 2021 at 20:49
  • @NickODell I didi try it and didn't work.. but I found out what the problem is. Thanks
    – Vincenzo
    May 21, 2021 at 21:09
  • 1
    You meant the ln -s "/Applications/Docker.app/Contents//Resources/bin/docker-credential-desktop" "/usr/local/bin/docker-credential-desktop" command? I'm not running the app.. The post before it actually say what's the correct credStore value is depending on Docker version.. in my case is Docker version 20.10.6, build 370c289
    – Vincenzo
    May 21, 2021 at 21:31
  • Same problem on WSL2/Ubuntu. The correct solution for WSL2 can be found in the [link]{github.com/docker/for-mac/issues/3785#issuecomment-642210534} (thanks [Nick ODell]{stackoverflow.com/users/530160/nick-odell}). All the other answers below are dangerous.
    – kingaj
    Aug 9 at 15:45
  • Same issue on WSL2/Ubuntu. @NickODell pointed to the correct thread. For WSL2 the answer is in this link. Almost all the answers below seem to be dangerous.
    – kingaj
    Aug 9 at 15:49

6 Answers 6

204

Check your ~/.docker/config.json and replace "credsStore" by "credStore"

{
  "stackOrchestrator" : "swarm",
  "experimental" : "disabled",
  "credStore" : "desktop"
}

11
  • 11
    ~/.docker/config.json this is a file path to be precise Sep 30, 2021 at 7:55
  • 3
    This solution worked fine for me on macOS Catalina. Dec 15, 2021 at 14:22
  • 4
    2022 August. I'm running docker Engine 20.10.17 on Mac Monterey with colima 0.4.4, no docker desktop. Changing "credsStore": "desktop" to `"credStore": "desktop" helped me solve the following problem with docker login: ``` Error saving credentials: error storing credentials - err: exec: "docker-credential-desktop": executable file not found in $PATH, out: `` ``` Aug 8, 2022 at 13:43
  • 15
    Note that credStore is not a valid config key (please correct me if I am wrong), so the only reason changing credsStore to credStore works is because you are effectively deleting the credStore entry. IMO it's better to just delete it, or rename it to something obviously placeholder, so that it's not misleading in future if you are reviewing your config. Oct 27, 2022 at 20:23
  • 7
    For users on Colima, you can set the value of credStore to colima. Jan 23 at 13:46
77

just in ~/.docker/config.json change credsStore to credStore

6
  • 2
    Ivan if you check my own answer ( the accepted one ) you'll see that it works with credsStore too.. the problem was tha value..nit the key
    – Vincenzo
    Oct 17, 2021 at 2:20
  • This worked for me on CentOS7. My error was docker.credentials.errors.InitializationError: docker-credential-pass not installed or not available in PATH when I ran docker-compose up -d. Thanks @Ivan.
    – skg
    Jul 6, 2022 at 10:29
  • 1
    This solved my issue, too. It was the key that was wrong, not the values in my case.
    – Meuko
    Aug 16, 2022 at 7:28
  • 10
    Note that, as far as I know, this solution is misleading: it works because credStore is not a valid key, and is ignored by Docker. It's equivalent to removing "credsStore": "desktop", which I would argue is better because if you are debugging your config in future to determine why Docker is not resolving credentials, it will be easy to miss the typo. Oct 27, 2022 at 20:20
  • Me too. @Vicenzo: I tried what you said, it is wrong. The key, in my case, has to be credStore.
    – jgomo3
    Feb 1 at 0:27
28

Since you're on a Mac, you could use docker-credential-osxkeychain instead.

  1. Install docker-credential-helper.

    brew install docker-credential-helper
    
  2. Verify docker-credential-osxkeychain is available.

    $ docker-credential-osxkeychain version
    0.6.4
    
  3. Set credsStore to osxkeychain in ~/.docker/config.json

    {
      "auths": {
        "https://index.docker.io/v1/": {}
      },
      "credsStore": "osxkeychain",
      "experimental": "enabled",
      "stackOrchestrator": "swarm"
    }
    
  4. Login to Docker Hub.

    $ docker login -u $USER
    Password: 
    Login Succeeded
    
5
  • 3
    This is the correct and the safest answer so far. In the above, all answers are bypassing the dynamic credentials. Using the binary of docker-credential-osxkeychain ensures that the credentials of the docker login are not stored in plaintext format.
    – redzack
    May 22 at 17:50
  • This worked for me. I don't know the version check, but after setting my docker config to the content supplied from number 3 above, I was up and running.
    – Scott
    Jun 19 at 20:22
  • Should be accepted as best answer for mac
    – kingaj
    Aug 9 at 15:53
  • Installing only docker-credential-helper (i.e. step 1) made it work.
    – y_159
    Aug 13 at 18:53
  • this is the correct answer. please see documentation docs.docker.com/engine/reference/commandline/login/…
    – Nardo
    Aug 22 at 15:27
22

After a long googling I found out that the problem is with the config.json file. The "credsStore" : "docker-credential-desktop" is wrong one in :

{
  "credsStore" : "docker-credential-desktop",
  "stackOrchestrator" : "swarm",
  "experimental" : "disabled"
} 

changed the "credsStore" key value to "desktop" and compose now works as expected. Some pointed out that credsDstore typo was the problem and fixed it with credDstore, but in my case the value was the problem, it works both with "credsStore" : "desktop" and "credStore" : "desktop".

Hope it'll help others starting out with Docker. Cheers.

3
  • I was looking for location of config.json. In my case it was ~/.docker/config.json. General documentation: docs.docker.com/engine/reference/commandline/cli/…
    – juhoautio
    Sep 16, 2021 at 14:09
  • 3
    "credsStore: "desktop" was the default value for a fresh install of Docker, version Docker version 20.10.16, build aa7e414. @Ivan's answer of changing credsStore (plural) to credStore (singular) did indeed fix the issue for me.
    – Dan
    Jun 9, 2022 at 0:08
  • This just turns off the credentials. The answer below is correct.
    – kingaj
    Aug 9 at 15:52
2

I ran into a similar issue using wsl2 on windows 10 while trying to locally invoke an aws lambda function. I was getting docker.credentials.errors.InitializationError: docker-credential-desktop not installed or not available in PATH when running sam build --use-container. Running which docker-credential-desktop showed no results

Upon further inspection I found that docker-credential-desktop.exe was in PATH however. After a quick google, it seems like enabling the wsl2 backend in Docker Desktop for Windows 10 symlinks wsl/docker-desktop/cli-tools/usr/bin/docker-credentials-desktop.exe to /usr/bin/docker-credential-desktop.exe. To fix this I simply removed the symlink and created a new one without .exe

To check the link and remove it:

user@device:~$ ls -l /usr/bin/docker-credential-desktop.exe
lrwxrwxrwx 1 root root 67 Jan  5 23:15 /usr/bin/docker-credential-desktop.exe -> /wsl/docker-desktop/cli-tools/usr/bin/docker-credential-desktop.exe
user@device:~$ sudo rm /usr/bin/docker-credential-desktop.exe

To create a new one without .exe and check it worked:

user@device:~$ sudo ln -s /wsl/docker-desktop/cli-tools/usr/bin/docker-credential-desktop.exe /usr/bin/docker-credential-desktop
user@device:~$ ls -l /usr/bin/docker-credential-desktop
lrwxrwxrwx 1 root root 67 Jan 12 14:22 /usr/bin/docker-credential-desktop -> /wsl/docker-desktop/cli-tools/usr/bin/docker-credential-desktop.exe

After that I sourced .bashrc to update PATH and the problem was resolved. I verified this with which docker-credential-desktop and it now shows the location specified in the symlink above.

3
  • 1
    Thanks for tracking this down. Just wanted to note that on my system, wsl is mounted on /mnt/wsl/. YMMV Mar 28, 2022 at 17:20
  • Thanks for pointing that out - I think /mnt/wsl is the default mount location. I vaguely recall changing my configuration or creating a symlink when I installed wsl2 on my machine. Apr 7, 2022 at 17:51
  • This is incorrect and can corrupt your installation. The correct answer is in the link posted by @NickODell in the first comment. For WSL, the answer is here
    – kingaj
    Aug 9 at 15:54
1

If your are on WSL, try desktop.exe, instead of desktop. Because you will find that the program in /usr/bin/ is docker-credential-desktop.exe.

{
   "credsStore": "desktop.exe"
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.