Windwos启动Docker失败
Windwos启动Docker失败
一、环境
windows10
PS C:\WINDOWS\system32> wsl --version
WSL 版本: 1.2.5.0
内核版本: 5.15.90.1
WSLg 版本: 1.0.51
MSRDC 版本: 1.2.3770
Direct3D 版本: 1.608.2-61064218
DXCore 版本: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows 版本: 10.0.19045.3324
二、现象
启动docker失败
An unexpected error was encountered while executing a WSL command. Common causes include access rights issues, which occur after waking the computer or not being connected to your domain/active directory.
Please try shutting WSL down (wsl --shutdown) and/or rebooting your computer. If not sufficient, WSL may need to be reinstalled fully. As a last resort, try to uninstall/reinstall Docker Desktop. If the issue persists please collect diagnostics and submit an issue (https://docs.docker.com/desktop/troubleshoot/overview/#diagnose-from-the-terminal).
启动wsl失败
C:\Users\ChengHaoQian>wsl
参考的对象类型不支持尝试的操作。
Error code: Wsl/Service/0x8007273d
三、解决办法
方案一:(临时的)
在powershell(管理员)中执行netsh winsock reset
命令
方案二:(不一定奏效)
- 在设置中,卸载WSL(Windows Subsystem for Linux);
- 在应用商店重新安装WSL(Windows Subsystem for Linux);
方案三:
NoLsp.exe
下载地址:http://www.proxifier.com/tmp/Test20200228/NoLsp.exe
-
使用步骤
管理员打开powershell,执行如下命令,获取应用商店版wsl安装目录
cd "C:\Program Files\WindowsApps"
ls
-
找到包含WindowsSubsystemForLinux字段就是,例如我电脑上是
MicrosoftCorporationII.WindowsSubsystemForLinux_2.0.9.0_x64__8wekyb3d8bbwe
-
管理员打开cmd,执行以下命令,下面的命令就相当于添加注册表(记得将
MicrosoftCorporationII.WindowsSubsystemForLinux_2.0.9.0_x64__8wekyb3d8bbwe
修改为上一步所找到的字段)
NoLsp.exe %USERPROFILE%\AppData\Local\Microsoft\WindowsApps\wsl.exe
NoLsp.exe "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_2.0.9.0_x64__8wekyb3d8bbwe\wsl.exe"
NoLsp.exe "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_2.0.9.0_x64__8wekyb3d8bbwe\wslservice.exe"
NoLsp.exe "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_2.0.9.0_x64__8wekyb3d8bbwe\wslg.exe"
NoLsp.exe "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_2.0.9.0_x64__8wekyb3d8bbwe\wslhost.exe"
-
结果如下
-
使用powershell脚本添加注册表项
$MethodDefinition = @' [DllImport("ws2_32.dll", CharSet = CharSet.Unicode)] public static extern int WSCSetApplicationCategory([MarshalAs(UnmanagedType.LPWStr)] string Path, uint PathLength, [MarshalAs(UnmanagedType.LPWStr)] string Extra, uint ExtraLength, uint PermittedLspCategories, out uint pPrevPermLspCat, out int lpErrno); '@ $UserProfilePath = $env:USERPROFILE $Ws2Spi = Add-Type -MemberDefinition $MethodDefinition -Name 'Ws2Spi' -PassThru $WslLocation = Get-AppxPackage MicrosoftCorporationII.WindowsSubsystemForLinux | Select-Object -expand InstallLocation $Executables = ("wsl.exe", "wslservice.exe","wslg.exe","wslhost.exe"); $Location = ($WslLocation,"C:\Program Files\WSL","C:\Windows\System32","${UserProfilePath}\AppData\Local\Microsoft\WindowsApps"); foreach ($Location in $Location){ foreach ($Exe in $Executables) { $ExePath = "${Location}\${Exe}"; $ExePathLength = $ExePath.Length; $PrevCat = $null; $ErrNo = $null; if ($Ws2Spi::WSCSetApplicationCategory($ExePath, $ExePathLength, $null, 0, [uint32]"0x80000000", [ref] $PrevCat, [ref] $ErrNo) -eq 0) { Write-Output "Added $ExePath!"; } } } Write-Output "success"; pause
四、参考