Windows容器无法启动的主因是镜像与宿主机OS版本不匹配,需通过winver或systeminfo获取宿主机build号(如10.0.22631),再用docker image inspect验证镜像OsVersion是否一致,严格匹配才能运行。
windows 容器无法启动,若错误日志中出现 “image operating system 'windows' does not match the host operating system 'linux'” 或类似提示,基本可确认是容器镜像与宿主机 windows 版本不匹配所致。windows 容器对 os 版本要求严格,必须精确匹配(如 windows server 2022 镜像不能在 windows 10 上运行,ltsc 镜像也不能混用于非 ltsc 主机)。
确认宿主机 Windows 版本和内部版本号
打开 PowerShell(无需管理员权限),运行:
winver
或更精确地获取内部版本号:
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
你将看到类似:
OS Name: Microsoft Windows 11 ProOS Version: 10.0.22631.4830
注意:关键不是“Windows 11”,而是 10.0.22631 这个内部版本号(即 build number)。Docker 拉取的镜像标签(如 mcr.microsoft.com/windows/servercore:ltsc2022)背后对应的是特定 build,必须与宿主机一致。
检查镜像的 OS 版本兼容性
使用以下命令查看本地已拉取镜像的 OS 元信息:
docker image inspect <IMAGE_NAME> --format='{{.Os}}/{{.OsVersion}}'
例如:
docker image inspect mcr.microsoft.com/windows/servercore:ltsc2022 --format='{{.OsVersion}}'
输出可能是 10.0.20348.2795 —— 这就是该镜像支持的 Windows build 号。若它与你宿主机的 10.0.22631.xxxx 不一致,就无法启动。
常见兼容关系(截至 2026 年主流版本):
- Windows 10 21H2 / Windows 11 21H2 → 对应 build
10.0.22000,需用:21H2或:ltsc2022(部分早期 ltsc2022 镜像也基于此) - Windows 11 22H2 / 23H2 → 对应 build
10.0.22621或10.0.22631,应选用标有:22H2、:23H2或明确标注build-22631的镜像 - Windows Server 2025 → build
10.0.26100,仅限 Server 环境,不兼容桌面版 Windows
强制指定兼容镜像并验证
不要依赖默认 latest 标签(它可能指向不兼容版本)。直接拉取明确匹配的镜像:
docker pull mcr.microsoft.com/windows/nanoserver:22H2<br>docker pull mcr.microsoft.com/windows/servercore:23H2
启动前先测试基础兼容性:
docker run --rm mcr.microsoft.com/windows/nanoserver:22H2 cmd /c echo "Hello from matching OS"
若报错 "The container operating system does not match the host operating system",说明仍不匹配;若成功输出,则镜像可用。
排查 Docker Desktop 和 WSL 2 干扰
即使你运行的是 Windows 容器,Docker Desktop 默认可能启用 WSL 2 后端——这本身不影响 Windows 容器,但若误启 Linux 容器模式或配置了跨平台构建上下文,可能导致镜像拉取错位。
请确认:
- Docker Desktop 设置 → General → 取消勾选 “Use the WSL 2 based engine”(仅当你纯用 Windows 容器时可关闭;若同时用 Linux 容器,请保留并确保切换到 Windows 容器模式)
- 右下角 Docker 图标右键 → 切换到 Windows containers(而非 Linux containers)
- PowerShell 中执行
docker version,检查 Server → Operating System 显示为windows,而非linux


















