在 Windows 上安装 Docker 的步骤如下(支持 Windows 10/11 Pro/Enterprise/Education 64位):
下载安装包:
Docker Desktop for Windows
版本。运行安装程序:
.exe
文件,按向导安装(默认勾选必要组件)。启用 WSL 2 或 Hyper-V(二选一):
powershell
# 以管理员身份运行 PowerShell,执行:
wsl --install
安装后重启电脑。powershell
# 启用 Hyper-V
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
重启后生效。启动 Docker Desktop:
验证安装:
docker --version
docker run hello-world
若看到欢迎信息,则安装成功。
家庭版默认不支持 Hyper-V,需通过以下方式:
1. 安装 WSL 2:
powershell
wsl --install
2. 手动下载 WSL 2 内核:
- 从微软官网下载 WSL 2 更新包。
3. 安装 Docker Desktop:
- 选择安装时使用 WSL 2 后端(无需 Hyper-V)。
Intel VT-x
或 AMD-V
。powershell
net stop com.docker.service
net start com.docker.service
json
"registry-mirrors": ["https://registry.docker-cn.com"]
完成以上步骤后,即可在 Windows 上使用 Docker 运行容器。如需进一步调试,可通过 docker info
查看详细配置。