1. 起因
在 Win10 中安装 Docker Desktop 后,结果发现这玩意启动报错:
System.InvalidOperationException: Failed to set version to docker-desktop: exit code: -1
此时,如果在 CMD 中执行 wsl 命令,同样也发现报错:
出现图中所示错误的原因是 代理软件 与 wsl2 的端口冲突。
2. 解决方案
2.1. 方案1(粗暴版)
netsh winsock reset
但是这个方案存在缺陷:
此操作会导致代理软件(proxifier)无法使用,请谨慎操作。 https://github.com/microsoft/WSL/issues/4194#issuecomment-636468984 https://github.com/microsoft/WSL/issues/4177#issuecomment-508826708
2.2. 方案2(改进版)
https://github.com/microsoft/WSL/issues/4177#issuecomment-597736482
其实是,上面这个 issue 中提到的此方案:
We have a tool that can make this call: http://www.proxifier.com/tmp/Test20200228/NoLsp.exe Please just run as admin with the full path to wsl.exe as the parameter: NoLsp.exe c:\windows\system32\wsl.exe
使用方法就是上面描述的,以管理员身份运行cmd后执行
NoLsp.exe c:\windows\system32\wsl.exe
由于众所周知的原因,我下载了一份 NoLsp.exe 放到了阿里云盘上,供大家下载:
https://www.aliyundrive.com/s/A6SGW1gcPyo
最后
我的 Docker Desktop 启动成功了
3. 小科普
3.1. WSL 是什么?
Windows Subsystem for Linux(简称WSL)是一个在Windows 10上能够运行原生Linux二进制可执行文件(ELF格式)的兼容层。它是由微软与Canonical公司合作开发,其目标是使纯正的Ubuntu、Debian等映像能下载和解压到用户的本地计算机,并且映像内的工具和实用工具能在此子系统上原生运行。
3.2. Proxifier 是什么?
Proxifier allows network applications that do not support working through proxy servers to operate through a SOCKS or HTTPS proxy or a chain of proxy servers. With Proxifier, you can easily tunnel all a system’s TCP connections or only those you select.
简单说,Proxifier 能让不支持代理的软件支持代理...
参考:
NoLsp.exe: http://www.proxifier.com/tmp/Test20200228/NoLsp.exe