在 Window 和 WSL 之间共享 docker 凭据

Mar*_*ssy 3 authentication credentials docker windows-subsystem-for-linux

环境

  • Windows 版本和内部版本 2004 版(操作系统内部版本 19037.1)
  • Docker Edge 版本 2.1.6.1
  • WSL 2 上的 Ubuntu 18.04

当前设置和状态:

  • docker安装在windows上
  • 为 docker、docker-compose、docker-credential-desktop 等创建了别名...

运行docker builddocker psdocker pull等命令docker images都可以正常工作。现在我想推送一个图像,所以我当然必须先登录。

问题:登录 docker hub。

  • docker login我在 WSL 终端中运行
  • 我输入了我的用户名和密码
  • 我收到以下错误
Error saving credentials: error storing credentials - err: exec: "docker-credential-desktop": executable file not found in %PATH
%, out: ``
Run Code Online (Sandbox Code Playgroud)

到目前为止我尝试过的

docker login来自 powershell 工作正常。/mnt/c/Users/<winusername>/.docker所以我在和之间创建了一个符号链接/home/<wslusername>/.docker。等效的方法适用于.aws,但.docker它无法共享甚至确认凭据,因此它再次要求输入用户和密码,并抛出与上面相同的错误。

小智 5

这对我有用,

sudo  ln -s /mnt/c/Program\ Files/Docker/Docker/resources/bin/docker-credential-desktop.exe /usr/bin/docker-credential-desktop.exe
Run Code Online (Sandbox Code Playgroud)

将可执行文件从 Windows 路径链接到 linux 路径,或者您可以将 Windows PATH 添加到 linux PATH 上。

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