'Docker: Stderr:fatal error: runtime: out of memory on AWS Elasticbeanstalk
Each time I am trying to build and deploy my React Project on AWS Elastic Beanstalk using Docker, I am getting this error:
Stderr:fatal error: runtime: out of memory
The project is the basic react project and nothing more, serving it via nginx. What might be the reason of this error? And how do I resolve it. Please note, I have emptied my S3 bucket and have restarted the appServer too, to try and resolve any unnecessary memory or cache use. And I am able to successfully build and run this file locally. The logs are as follows:
Step 1/9 : FROM node:alpine as builder
---> eb56d56623e5
Step 2/9 : WORKDIR '/app'
---> Using cache
---> 41d7415dae07
Step 3/9 : COPY package.json .
---> Using cache
---> 95877ba9972c
Step 4/9 : RUN npm install
---> Using cache
---> c366758de80f
Step 5/9 : COPY . .
---> 5697eace7031
Step 6/9 : RUN npm run build
---> Running in 52cc1a3e6ac0
> [email protected] build
> react-scripts --openssl-legacy-provider build
Creating an optimized production build...
2022/03/03 13:14:45.346275 [WARN] failed to execute command: docker build -t aws_beanstalk/staging-app /var/app/staging/, retrying...
2022/03/03 13:14:45.425369 [INFO] Running command /bin/sh -c docker build -t aws_beanstalk/staging-app /var/app/staging/
2022/03/03 13:14:47.001398 [ERROR] An error occurred during execution of command [app-deploy] - [Docker Specific Build Application]. Stop running the command. Error: failed to build docker image: Command /bin/sh -c docker build -t aws_beanstalk/staging-app /var/app/staging/ failed with error exit status 2. Stderr:fatal error: runtime: out of memory
Solution 1:[1]
You docker image does not enough memory allocated:
In the ElasticBeanstalk application environment Dockerrun.aws.json, you can increase the memory allocation ("memory": 80 to e.g. "memory": 100):
"containerDefinitions": [
{
"name": "request_repeater",
"image": "my/image",
"essential": true,
"memory": 80, <- change this
Also, maybe you need to change the instance type. For example the t2.nano has a max memory of 0.5 GB
You can do this in Modify capacity settings when you are creating your application, or edit in Configuration > Capacity setting on the current env configuration.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
