Mark Chassy
Mark Chassy

Reputation: 159

Sharing docker credentials between Window and WSL

Environment

Current setup and status:

Running commands such as docker build, docker ps, docker pull, docker images all work fine. Now I would like push an image and so of course I have to login first.

Problem: logging into docker hub.

Error saving credentials: error storing credentials - err: exec: "docker-credential-desktop": executable file not found in %PATH
%, out: ``

What I've tried so far

docker login from powershell works fine. So I created a symbolic link between /mnt/c/Users/<winusername>/.docker and /home/<wslusername>/.docker. The equivalent works fine for .aws, but for .docker it was not able to share or even acknowledge the credentials, so it asked again for the user and password and threw the same error as above.

Upvotes: 3

Views: 13959

Answers (2)

Mark Chassy
Mark Chassy

Reputation: 159

Update Feb 2021

This is all much simpler now. If you are using WSL2 on a recent release of Windows, just install docker on the Windows side and ensure to configurations:

  • In General: us the WSL 2 based engine
  • In Resource/WSL Integration: enable integration with your default WSL distro

You will have to restart docker. Once it is done, everything works transparently.

Below here can be ignored

It turns out that the integration between Docker and WSL is better than I thought. Though it could have been better documented. I was going to change tack and try to install docker in the WSL. So I got rid of all the aliases and restarted my session. Lo and behold, when I ran docker there was still something running.

This is because the edge version of docker create the appropriate symbolic links and now I login into docker hub without any problem.

Upvotes: 2

Antonio Marques
Antonio Marques

Reputation: 51

This worked for me,

sudo  ln -s /mnt/c/Program\ Files/Docker/Docker/resources/bin/docker-credential-desktop.exe /usr/bin/docker-credential-desktop.exe

Linking the executable from windows path to linux path or you can add the windows PATH on you linux PATH.

Refer: https://github.com/docker/for-win/issues/6652

Upvotes: 5

Related Questions