Docker:运行使用依赖项构建的映像时出现超时错误



我的目标是创建一个容器,我可以在其中:

  1. 输入数据
  2. 处理可执行 (.exe( 文件上的数据
  3. 输出已处理的数据

我想使用 NodeJS 来处理 REST 的输入/输出。 因此,我需要在容器上安装 NodeJS 以及可执行文件的依赖项。

我的 Dockerfile 现在看起来像这样:

FROM microsoft/windowsservercore
COPY installers installers
COPY sources sources
COPY ProjectXYZ ProjectXYZ
# Install NodeJS and dependencies
RUN cd C:installers && 
msiexec.exe /qn /i "node-v8.11.3-x64.msi" && 
Jet40SP8_9xNT.exe /Q && 
setup.exe /configure configuration.xml && 
DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:C:sourcessxs && 
DISM /Online /Enable-Feature /FeatureName:NetFx4 /All /LimitAccess && 
cd C: && 
rmdir /s /q sources && 
rmdir /s /q installers
# Start the service 
ENTRYPOINT "cd C:/ProjectXYZ && node server.js"

此 Dockerfile 虽然由于某些下载而需要很长时间,但构建成功。

PS C:projectxyz> docker build -t projectxyz .
Sending build context to Docker daemon  207.1MB
Step 1/6 : FROM microsoft/windowsservercore
---> 7d89a4baf66c
Step 2/6 : COPY installers installers
---> Using cache
---> 1538d7a0ba9d
Step 3/6 : COPY sources sources
---> Using cache
---> 659167fb1238
Step 4/6 : COPY HiperPlantNodeJS HiperPlantNodeJS
---> Using cache
---> e8295924e730
Step 5/6 : RUN cd C:installers &&     Jet40SP8_9xNT.exe /Q &&     msiexec.exe /qn /i "node-v8.11.3-x64.msi" &&     setup.exe /configure configuration.xml &&     DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:C:sourcessxs &&     DISM /Online /Enable-Feature /FeatureName:NetFx4 /All /LimitAccess &&     cd C: &&     rmdir /s /q sources &&     rmdir /s /q installers
---> Using cache
---> 1ebbf13b0d3c
Step 6/6 : ENTRYPOINT "cd C:/HiperPlantNodeJS && node server.js"
---> Running in c8a8af429021
Removing intermediate container c8a8af429021
---> c042e6756ef4
Successfully built c042e6756ef4
Successfully tagged projectxyz:latest
PS C:projectxyz>

但是,运行生成的映像时始终会出现超时错误。

PS C:projectxyz> docker images
REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE
projectxyz                    latest              1519b739fc1d        7 minutes ago       14.4GB
microsoft/windowsservercore   latest              7d89a4baf66c        5 weeks ago         10.7GB
PS C:projectxyz> docker run --name=xyz01 -p 8765:4321 -d hpnodejs-cmd
74b8a68f25dac38fa715611d597c017b63ba1376974f63f91e10c645df5b2e0e
C:Program FilesDockerDockerResourcesbindocker.exe: Error response from daemon: container 74b8a68f25dac38fa715611d597c017b63ba1376974f63f91e10c645df5b2e0e encountered an error during Start: failure in a Windows system call: This operation returned because the timeout period expired. (0x5b4)

但是,如果我以交互方式运行映像(没有依赖项(并在容器中手动安装依赖项,则一切正常。容器和项目按预期运行。

我正在尝试制作的系统需要创建此容器的多个副本,并在分离模式下运行每个副本。因此,为每个容器手动安装依赖项已经是不可能的。

主要问题:如何操作才能成功运行此映像?

运行大图像是否有限制? 因为如您所见,安装依赖项后,映像现在为 14.5GB。 我在文档中找不到任何提及它的内容。

感谢您的帮助。

因为我喜欢回答问题:

当我遇到这个问题时,它似乎变成了一个Microsoft/Docker错误:https://github.com/Microsoft/hcsshim/issues/152#issuecomment-462888500。你可以在那里看到我的帖子。

本质上,具有 hyper-v 隔离的 docker 存在内存交换问题。我通过减少系统内存消耗(释放空间(和使用-m参数来解决这个问题(2GB 对我来说似乎是最佳选择,但偶尔将其更改为 3 或 4 会有所帮助。

最新更新