我的目标是创建一个容器,我可以:
我想使用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:\sources\sxs && \
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:\sources\sxs && 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 Files\Docker\Docker\Resources\bin\docker.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。你可以在那里看到我的帖子。
基本上关于具有超v隔离的docker的东西存在内存交换问题。我通过减少系统内存消耗(释放空间)和使用-m
参数来解决这个问题(2GB对我来说似乎是最佳选择,但偶尔会将其改为3或4帮助。)