[Docker]解决Windows Docker 与 其他代理软件冲突导致无法启动问题

问题

具体问题为使用某些加速器或者Proxifier后,Docker Desktop出现无法启动

解决方案1:如果MicroSoft Store中没有下载Windows Subsystem for Linux

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\0408F7A3]
"AppFullPath"="C:\\Windows\\System32\\wsl.exe"
"PermittedLspCategories"=dword:80000000

解决方案2:如果MicroSoft Store中下载了Windows Subsystem for Linux

使用以下Power Shell脚本

#Requires -RunAsAdministrator

$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);
'@

$Ws2Spi = Add-Type -MemberDefinition $MethodDefinition -Name 'Ws2Spi' -PassThru

$WslLocation = Get-AppxPackage MicrosoftCorporationII.WindowsSubsystemForLinux | Select-Object -expand InstallLocation

$Executables = ("wsl.exe", "wslservice.exe");

foreach ($Exe in $Executables) {
    $ExePath = "${WslLocation}\${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!";
    }
}

以管理员命令执行,若报错需检查powershell策略,管理员界面执行Set-ExecutionPolicy Bypass后执行该脚本,再还原Set-ExecutionPolicy Restricted

因为Microsoft Store应用更新包名似乎会随机化以下,他默认更新后需重新执行该脚本

解决方案3: 临时方案

netsh winsock reset
posted @ 2023-09-16 21:01  小天呜啦啦  阅读(356)  评论(1)    收藏  举报