ng build在Docker中返回致命的内存不足异常 [英] ng build returns fatal out of memory exception in Docker

查看:292
本文介绍了ng build在Docker中返回致命的内存不足异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Node.js Docker容器中构建Web应用程序的前端。当我使用Windows PC时,我的基本图像非常有限。我选择了这一个,因为它是DockerHub上唯一一个像样的下载次数。由于该应用程序旨在在Azure中运行,因此我也仅限于Windowsservercore2016。当我运行以下Dockerfile时,我收到以下错误消息(在我的主机系统上,运行正常btw):

I'm trying to build the frontend of a web application in a Node.js Docker container. As I'm on a Windows PC, I'm very limited in my base Images. I chose this one, as it's the only one on DockerHub with a decent number of downloads. As the application is meant to run in Azure, I'm also limited to Windowsservercore 2016. When I run the following Dockerfile, I get the error message below (on my host system the build runs fine btw):

FROM stefanscherer/node-windows:10.15.3-windowsservercore-2016
WORKDIR /app

RUN npm install -g @angular/cli@6.2.4

COPY . ./

RUN ng build







#
# Fatal error in , line 0
# API fatal error handler returned after process out of memory on the background thread
#
#
#
#FailureMessage Object: 000000E37E3FA6D0

我尝试增加-max_old_space 用于构建过程的可用内存最大为16GB(笔记本电脑的整个RAM),但这没有帮助。我还联系了基础图像的作者,以查明是否是问题所在,但由于使用较小的示例应用程序似乎无法重现此问题,因此效果也不佳。我已经在这个问题上工作了一个星期,但我真的不知道这可能是什么原因。因此,我希望从这里获得新的动力。至少我可以调查一下。

I tried increasing the memory available to the build process with --max_old_space up to 16GB (the entire RAM of my laptop) but that didn't help. I also contacted the author of the base image to find out if that's the issue but as this doesn't seem to be reproducable with a smaller example application, that wasn't very fruitful either. I'm working on this issue for a week now and I'm seriously out of ideas what could be the reason. So I hope to get a new impulse from here. At least a dircetion I could investigate in.

我还试图在Windowsservercore基本映像上安装Node.js和Angular。如果有人知道如何执行此操作,则可能是解决方案。

What I also tried was getting Node.js and Angular installed on a Windowsservercore base image. If someone has an idea how to do that, it could be the solution.

编辑:我注意到错误消息是 only 输出我从构建过程中学到了,甚至不必尝试构建模块。也许这意味着...

I noticed that the error message is the only output I get from the build process, it doesn't even get to try building the modules. Maybe that means something...

推荐答案

算法,我已经弄清楚了。尽管正式的Docker文档指出,Docker可以无限制地访问资源,但是当您的构建过程中存在一定数量的内存时,似乎需要使用-m选项。

Alrigth, I figuered it out. Although the official Docker documentation states, that Docker has unlimited access to resources, it seems that you need to use the -m option when your build process exeeds a certain amount of memory.

这篇关于ng build在Docker中返回致命的内存不足异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆