[英]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.