Windows 10启动Docker Desktop失败,出现WSL磁盘挂载错误
报错信息:
provisioning docker WSL distros: ensuring main distro is deployed:
checking if main distro is up to date: checking main distro bootstrap
version: getting main distro bootstrap version: exit code: 4294967295:
running WSL command wsl.exe C:\WINDOWS\System32\wsl.exe -d
docker-desktop -u root -e wsl-bootstrap version: Failed to attach disk
'\AppData\Local\Docker\wsl\distro\ext4.vhdx' to WSL2: The system
cannot find the file specified.
Error code: Wsl/Service/CreateInstance/MountVhd/HCS/ERROR_FILE_NOT_FOUND
报错原因:
Docker依赖的WSL2磁盘文件ext4.vhdx丢失或路径异常,导致无法挂载到WSL2环境,进而无法启动Docker Desktop。
解决步骤:
停止相关服务
打开命令提示符(CMD)或PowerShell,执行命令停止WSL和Docker服务:wsl --shutdown net stop com.docker.service清理损坏文件
打开文件资源管理器,导航到C:\Users\<你的用户名>\AppData\Local\Docker\wsl\distro,删除其中的ext4.vhdx文件(找不到则跳过)。重置Docker WSL集成
打开Docker Desktop设置,进入Resources > WSL Integration,先关闭所有启用的WSL发行版,点击Apply & Restart;重启后重新启用目标发行版,再次点击Apply & Restart。重建WSL发行版
若上述步骤无效,打开PowerShell执行命令卸载Docker的WSL发行版:wsl --unregister docker-desktop wsl --unregister docker-desktop-data重启Docker Desktop,它会自动重建所需的WSL磁盘文件。
检查WSL版本兼容性
执行命令确认WSL版本:wsl --list --verbose若存在版本为1的发行版,执行命令转换为2:
wsl --set-version <发行版名称> 2同时确保Windows 10版本为2004及以上(内部版本19041+),过低版本不支持WSL2。
内容的提问来源于stack exchange,提问作者Sadegh Ghanbari

