简体   繁体   English

Dockerfile中的Docker构建无限期挂起,偶尔会因错误“无法启动服务实用程序VM”而崩溃

[英]Docker build from Dockerfile hangs indefinitely and occasionally crashes with error 'failed to start service utility VM'

I am currently using Docker Desktop for Windows and following this tutorial for using Docker and VSCode ( https://scotch.io/tutorials/docker-and-visual-studio-code ) and when I am attempting to build the image, the daemon is able to complete the first step of the Dockerfile, but then hangs indefinitely on the second step. 我目前正在使用Docker Desktop for Windows,并按照本教程使用Docker和VSCode( https://scotch.io/tutorials/docker-and-visual-studio-code ),当我尝试构建映像时,守护程序能够完成Dockerfile的第一步,但在第二步无限期挂起。 Sometimes, but very rarely, after an indeterminate amount of time, it will error out and give me this error 有时,但很少,经过不确定的时间后,它会出错并给我这个错误

failed to start service utility VM (createreadwrite): CreateComputeSystem 97cb9905dbf6933f563d0337f8321c8cb71e543a242cddb0cb09dbbdbb68b006_svm: The operation could not be started because a required feature is not installed.
(extra info: {"SystemType":"container","Name":"97cb9905dbf6933f563d0337f8321c8cb71e543a242cddb0cb09dbbdbb68b006_svm","Layers":null,"HvPartition":true,"HvRuntime":{"ImagePath":"C:\\Program Files\\Linux Containers","LinuxInitrdFile":"initrd.img","LinuxKernelFile":"kernel"},"ContainerType":"linux","TerminateOnLastHandleClosed":true})

I have made sure that virtualization is enabled on my machine, uninstalled and reinstalled Docker, uninstalled Docker and deleted all files related to it before reinstalling, as well as making sure that the experimental features are enabled. 我确保在我的机器上启用了虚拟化,卸载并重新安装了Docker,卸载了Docker,并在重新安装之前删除了与之相关的所有文件,并确保启用了实验性功能。 These are fixes that I have found from various forums while trying to find others who have had the same issue. 这些是我在各种论坛中找到的修复程序,同时试图找到遇到同样问题的其他人。

Here is the Dockerfile that I am trying to build from. 这是我想要构建的Dockerfile。 I have double checked with the tutorial that it is correct, though its still possible that I missed something (outside of the version number in the FROM line). 我已经对教程进行了双重检查,认为它是正确的,尽管我仍然可能错过了一些东西(在FROM行中的版本号之外)。

FROM node:10.13-alpine
ENV NODE_ENV production
WORKDIR /usr/src/app
COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
RUN npm install --production --silent && mv node_modules ../
COPY . .
EXPOSE 3000
CMD npm start

I would expect the image to build correctly as I have followed the tutorial to a T. I have even full reset and started the tutorial over again and I'm still getting this same issue where it hangs indefinitely. 我希望图像能够正确地构建,因为我已经按照教程进行了测试。我甚至完全重置并重新开始教程,我仍然会遇到无限期挂起的同样问题。

well, you copy some files two times. 好吧,你复制一些文件两次。 I would not do that. 我不会这样做。
so for the minimum change to your Dockerfile I would try: 所以对于Dockerfile的最小更改,我会尝试:

FROM node:10.13-alpine
ENV NODE_ENV production
WORKDIR /usr/src/app
COPY . .
RUN npm install --production --silent && mv node_modules ../
EXPOSE 3000
CMD npm start

I would also think about the && mv node_modules ../ part, if it is really needed. 如果确实需要,我还会考虑&& mv node_modules ../部分。
If you don't do it already I advise you to write a .dockerignore file right next to your Dockerfile with the minimum content of: 如果你不这样做,就我劝你写一个.dockerignore文件旁边的Dockerfile与最小内容:

/node_modules

so that your local node_modules directory does not get also copied while building the image (saves time). 这样在构建映像时也不会复制本地node_modules目录(节省时间)。

hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Dockerfile中的docker build错误 - docker build error in Dockerfile new Builder()。forBrowser('chrome')。build()无限期挂起 - new Builder().forBrowser('chrome').build() hangs indefinitely 使用 Dockerfile 时,用于生产的 Strapi 构建挂起 - Strapi build for production hangs when using Dockerfile 从Node.js将dockerfile字符串插入`docker build`无法正常工作 - Piping a dockerfile string to `docker build` from Node.js is not working docker 构建跳过 Dockerfile CMD - docker build skipping Dockerfile CMD Alexa技能偶尔死亡/崩溃/退出,没有错误 - Alexa skill dies/crashes/quits occasionally with no error Docker 没有错误地构建 npm 脚本失败 - Docker failed to build npm script without Error Docker,启动服务失败:无法为运行时启动新的语言工作者:节点。 Apple M1 有问题吗? - Docker, failed to start service: Failed to start a new language worker for runtime: node. Problem with Apple M1? ./asinstall 在使用 dockerfile 进行 docker 构建时未找到? - ./asinstall not found in while docker build using dockerfile? 如何使用 docker-compose 文件中的命名图像和指定图像的 Dockerfile 启动命名 NodeJS 容器? - How to start a named NodeJS container with a named image from a docker-compose file and and a Dockerfile specifying the image?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM