ERROR: failed to solve: error getting credentials - err: exit status 1, out: ``

I recently installed Docker on my Mac air m2.
I was following the documentation for docker setup but I am facing the error while building the application

[+] Building 3.6s (2/3)                                                         
[+] Building 3.7s (3/3) FINISHED                                                
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 2B                                            0.0s
 => [internal] load build definition from Dockerfile                       0.0s
 => => transferring dockerfile: 281B                                       0.0s
 => ERROR resolve image config for           3.7st
 > resolve image config for
   1 | >>> # syntax=docker/dockerfile:1
   2 |     
   3 |     FROM node:18-alpine
ERROR: failed to solve: error getting credentials - err: exit status 1, out: ``

I have logged in using the docker login command and it was successful. I even tried to turn off build kits but there was no change in the error.
Can anyone please share a resolution for this.

1 Like

Check your client config file: $HOME/.docker/config.json. You should find something like this in that file:

"credsStore": "desktop",

or any other credStore. If it is not “desktop”, you can try to change it. This is what I use. I think the previous one was “osxkeychain”.

Some other ideas:

If you log in via SSH, you might need to unlock the keychain manually, however I don’t think that is what the error message indicates, but you can try it

security -v unlock-keychain ~/Library/Keychains/login.keychain-db

Another credentialrelated recent issue was when someone started to use “sudo” in front of the docker command. Docker Desktop is running on behalf of your non-root user so you don’t need sudo and that would use the credentials of the root user. In that case sudo seemed required only because somehow the docker cli was not executable without that and we had to fix it.

1 Like

The config files contains the value desktop only.
If I run docker build without sudo it gives me permission error
ERROR: open /Users/vineeth/.docker/buildx/activity/default: permission denied .
When I run using sudo the process stops with the same error I posted earlier. Is there any other way to solve this?

This is the topic I mentioned before

Try what I described there to make the docker command executable again.

Out of curiosity, did you install Docker Desktop as root? I know HomeBrew can also install Docker desktop but if you run it as root it might break the file permissions at least from your non-root user’s point of view.

Of course you have a different permission issue. Sorry I answered too quickly. So just make the docker folder writable by you like this:

sudo chown -R $(id -u):$(id -g) $HOME/.docker

Thank you! You saved my last an hour.

MacOS - I just had to change the docker config file.
The “credsStore” was “desktop” and changed it to “osxkeychain”.
used nano to do it. sudo nano ~/.docker/config.json

1 Like

Worked for me! Thanks