78

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?

Sunny Patel
  • 7,830
  • 2
  • 31
  • 46
Vincenzo
  • 5,304
  • 5
  • 38
  • 96
  • 1
    Can you try [this solution](https://github.com/docker/for-mac/issues/3785#issuecomment-518620870)? – Nick ODell May 21 '21 at 20:49
  • @NickODell I didi try it and didn't work.. but I found out what the problem is. Thanks – Vincenzo May 21 '21 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 '21 at 21:31
  • Same problem on WSL2/Ubuntu. The correct solution for WSL2 can be found in the [link]{https://github.com/docker/for-mac/issues/3785#issuecomment-642210534} (thanks [Nick ODell]{https://stackoverflow.com/users/530160/nick-odell}). All the other answers below are dangerous. – kingaj Aug 09 '23 at 15:45
  • Same issue on WSL2/Ubuntu. @NickODell pointed to the correct thread. For WSL2 the answer is in this [link](https://github.com/docker/for-mac/issues/3785#issuecomment-642210534). Almost all the answers below seem to be dangerous. – kingaj Aug 09 '23 at 15:49

6 Answers6

192

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

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

sixrandanes
  • 2,483
  • 2
  • 11
  • 10
  • Yes indeed that was the problem as I already found out and published in my answer, but thanks for answering. Cheers. – Vincenzo Jul 01 '21 at 10:19
  • 11
    `~/.docker/config.json` this is a file path to be precise – Pavol Travnik Sep 30 '21 at 07:55
  • 3
    This solution worked fine for me on macOS Catalina. – Carl Winbäck Dec 15 '21 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: `` ``` – Serdar Dalgic Aug 08 '22 at 13:43
  • 14
    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. – Ashley Davies Oct 27 '22 at 20:23
  • 7
    For users on [Colima](https://github.com/abiosoft/colima), you can set the value of `credStore` to `colima`. – Jeet Banerjee Jan 23 '23 at 13:46
  • 1
    Worked fine for me on Windows 10 WSL (Ubuntu 22.04.1 LTS). Thanks! – GDumphart Feb 20 '23 at 09:55
  • 1
    It also works by deleting the `credsStore` entry. – debashish.ghosh Apr 07 '23 at 13:48
  • https://stackoverflow.com/a/72888813/10215243 -- this is the real fix, other's are a hack/workaround. – redzack May 22 '23 at 17:51
  • This is really strange how I had to change this while i "only threw away some containers"... anyway. It worked on my Ubuntu 22.04 – Pianoman Jun 10 '23 at 18:45
75

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

Ivan
  • 2,316
  • 2
  • 24
  • 22
  • 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 '21 at 02: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 06 '22 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 '22 at 07: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. – Ashley Davies Oct 27 '22 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 01 '23 at 00:27
  • This is incorrect and dangerous. It turns off the credentials store. The correct answer is [above](https://stackoverflow.com/a/72888813/5445739) – kingaj Aug 09 '23 at 15:56
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
    
3ch01c
  • 2,336
  • 2
  • 17
  • 15
  • 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 '23 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 '23 at 20:22
  • Should be accepted as best answer for mac – kingaj Aug 09 '23 at 15:53
  • Installing only `docker-credential-helper` (i.e. step 1) made it work. – y_159 Aug 13 '23 at 18:53
  • this is the correct answer. please see documentation https://docs.docker.com/engine/reference/commandline/login/#credential-stores – Nardo Aug 22 '23 at 15:27
21

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.

phyatt
  • 18,472
  • 5
  • 61
  • 80
Vincenzo
  • 5,304
  • 5
  • 38
  • 96
  • I was looking for location of `config.json`. In my case it was `~/.docker/config.json`. General documentation: https://docs.docker.com/engine/reference/commandline/cli/#docker-cli-configuration-file-configjson-properties – juhoautio Sep 16 '21 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 09 '22 at 00:08
  • This just turns off the credentials. The answer [below](https://stackoverflow.com/a/72888813/5445739) is correct. – kingaj Aug 09 '23 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.

  • 1
    Thanks for tracking this down. Just wanted to note that on my system, `wsl` is mounted on `/mnt/wsl/`. YMMV – Jon 'links in bio' Ericson Mar 28 '22 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. – clayajohnson Apr 07 '22 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](https://github.com/docker/for-mac/issues/3785#issuecomment-642210534) – kingaj Aug 09 '23 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"
}