You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows容器中Docker RUN命令执行失败问题求助

问题描述

在Windows 11系统的Docker Desktop中切换至Windows容器后,执行docker build时,Dockerfile中的任意RUN命令都会失败,报错信息:

encountered an error during hcsshim::System::Start: failure in a Windows system call: Illegal operation attempted on a registry key that has been marked for deletion. (0x3fa)

Docker信息:

Server:
 Containers: 18
  Running: 0
  Paused: 0
  Stopped: 18
 Images: 65
 Server Version: 20.10.17
 Storage Driver: windowsfilter
  Windows:
 Logging Driver: json-file
 Plugins:
  Volume: local
  Network: ics internal l2bridge l2tunnel nat null overlay private transparent
  Log: awslogs etwlogs fluentd gcplogs gelf json-file local logentries splunk syslog
 Swarm: inactive
 Default Isolation: hyperv
 Kernel Version: 10.0 22000 (22000.1.amd64fre.co_release.210604-1628)
 Operating System: Windows 10 Enterprise Version 2009 (OS Build 22000.1936)
 OSType: windows
 Architecture: x86_64
 CPUs: 4

测试用Dockerfile:

FROM mcr.microsoft.com/windows/servercore:ltsc2019
COPY hello.txt C:
RUN ECHO "HELLO-WORLD"
CMD ["cmd", "/C", "type C:\\hello.txt"]

已尝试的方案:

  • 卸载并重装不同版本的Docker Desktop
  • 移除Windows 11近期的安全更新
  • 偶尔镜像构建成功,但多次尝试后仍会报错
  • 尝试使用不同的Windows基础镜像,无效
  • 执行docker system prune,无效
替代Docker构建Windows容器的工具
  • BuildKit(Docker内置增强引擎):无需额外安装,启用后能提升Windows容器构建的稳定性。执行构建时添加环境变量:set DOCKER_BUILDKIT=1 && docker build -t your-image-name .,也可以在Docker Desktop的设置中永久开启BuildKit选项。
  • Podman:兼容Docker命令的容器工具,无后台守护进程,支持Windows容器构建。安装后直接用podman build替代docker build,Dockerfile无需修改,能避开Docker Desktop的注册表相关问题。
  • Packer:HashiCorp的镜像构建工具,支持Windows容器镜像生成。编写HCL格式的Packer模板定义构建流程,可直接与Windows容器底层交互,生成的镜像可推送至仓库或本地使用,适合复杂构建场景。
  • PowerShell容器命令:微软官方提供的原生工具,通过New-ContainerImage等PowerShell cmdlet手动构建镜像。步骤虽繁琐,但完全绕开Docker Desktop,适合调试和定制化需求。

内容的提问来源于stack exchange,提问作者user804401

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 23:07:30