一、问题现象
启动Docker Desktop时弹出报错:
Hypervisor not present
Check that hardware-assisted virtualization (either Intel VMX or AMD SVM) and Data Execution Prevention are enabled in your BIOS.
命令行执行docker run hello-world提示:
docker: error during connect: Head "http://%2F%2F.%2Fpipe%2Fdocker_engine/_ping": open //./pipe/docker_engine: The system cannot find the file specified.
二、问题成因
Docker依赖硬件虚拟化(Intel VT-x/AMD-V)和系统虚拟化组件,以下情况会导致失效:
- 硬件虚拟化被BIOS禁用(误操作、软件修改、固件更新后默认关闭);
- 系统虚拟化组件(WSL子系统、虚拟机平台)被禁用/卸载;
- Hyper-V启动配置被篡改(设为
off)。
三、修复步骤
1. 修复系统虚拟化配置(管理员命令行)
# 检查Hyper-V启动状态
bcdedit | findstr /i "hypervisorlaunchtype"
# 设为自动启用
bcdedit /set hypervisorlaunchtype auto
# 启用WSL和虚拟机平台组件
dism /online /enable-feature /featurename:VirtualMachinePlatform /all /quiet
dism /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /quiet
# 重启电脑
shutdown /r /t 0
2. 验证硬件虚拟化(若步骤1无效)
- 命令行检查:
systeminfo | findstr /i "虚拟化",需显示“已启用”; - 任务管理器:「性能」→「CPU」→ 右下角查看虚拟化状态;
- 若禁用:重启电脑按对应按键(Dell=F2、HP=F10、联想=F1/F2、华硕=Del)进入BIOS,启用Intel VT-x/AMD-V,保存重启。
3. 配置Docker与WSL集成
- 管理员身份启动Docker Desktop;
- 「Settings」→「Resources」→「WSL Integration」,勾选默认发行版集成;
- 点击「Apply & Restart」。
4. 验证修复
docker --version
docker run hello-world
成功输出“Hello from Docker!”即修复完成。
四、预防建议
- 备份配置:
bcdedit /export "C:\虚拟化配置备份.bat",后续可通过bcdedit /import快速恢复; - 避免误操作:不随意禁用系统底层组件,安装软件时谨慎选择“修改系统配置”选项。