windows - docker 镜像构建卡住了

标签 windows docker containers

我需要为 windows 10 上的窗口应用程序构建一个 windows docker 镜像,并在 vm 上安装了 docker 桌面,但是在运行此应用程序的安装时构建过程卡住了。日志看起来像下面的东西,

PS C:\docker> docker image build . -t app
Sending build context to Docker daemon  144.1MB
Step 1/6 : FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8
 ---> 9b87edf03093
Step 2/6 : COPY . /app
 ---> ac4b1124d856
Step 3/6 : WORKDIR /app
 ---> Running in cf4bd2345d26
Removing intermediate container cf4bd2345d26
---> d4f28097afd9
Step 4/6 : RUN .\ELSA1.0_2.6.6.243.exe
---> Running in b9356f975aa6
(And the process is stuck for several hours here and is terminated by me)

docker 文件是
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8 # this is a base image because asp.net 3.5 is a prerequisite for the app

COPY . /app

WORKDIR /app

RUN .\ELSA1.0_2.6.6.243.exe # I am stuck here!

我试图像这样在基本图像中做一些事情,但似乎我无能为力
PS C:\docker> docker container run  -it 
mcr.microsoft.com/dotnet/framework/aspnet:4.8

 Service 'w3svc' has been stopped

 Service 'w3svc' started

有什么好的想法来调试这个问题吗?顺便说一句,安装程序可以在 Windows 10 上正常工作。

最佳答案

永远不要执行 RUN 中的命令。不终止的声明。我在您启动的 Docker 构建日志中看到 exe文件在 RUN命令。这将使您的 docker 构建过程卡住并等待 SIGINT .如果您执行 RUN npm start,也会发生同样的情况所以它会挂起构建过程。

在入口点或 CMD 添加您的可执行文件。

在这种情况下,另一件事可能是问题

在 Windows 中使用 CMD 的注意事项

On Windows, file paths specified in the CMD instruction must use forward slashes or have escaped backslashes \. The following are valid CMD instructions:


dockerfile
# exec form

CMD ["c:\\Apache24\\bin\\httpd.exe", "-w"]

# shell form

CMD c:\\Apache24\\bin\\httpd.exe -w

您可以进一步了解 Window CMD here

但是,以下没有正确斜杠的格式将不起作用:

dockerfile
CMD c:\Apache24\bin\httpd.exe -w

关于windows - docker 镜像构建卡住了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57848257/

相关文章:

docker - 在另一个服务中重用由一个服务构建的图像

docker - 无法连接到 Docker Redis(Redis 已启动并正在运行)

docker - 如何保持Hello-world容器运行

api - Kubernetes Horizo​​ntal Pod Autoscaler 如何计算多容器 Pod 的 CPU 利用率?

c++ - 为资源管理器创建右键单击菜单

python - 超时功能(Windows)?

docker - 在 Windows Server 2016 上构建 Docker 镜像

c# - 目录存在在桌面与服务器上产生不一致的结果

c++ - 在没有 Chrome 的情况下运行 Chrome Native Client (NaCL) 插件

css - 为移动设备重新排列容器