compose up - reason=RESOURCE:MEMORY
Not sure if this an issue with amazon-ecs-cli as it could be my config.
INFO[0000] Couldn't run containers reason=RESOURCE:MEMORY
when running ecs-cli compose up.
Is this because of a docker-compose misconfig? I don't get this problem when runnning docker-compose up locally. What exactly is a resource in this context? I'm thinking it could be due to mem_limit being set wrong in docker-compose.yml
Hi, I have the same error. How did you fixe it ?
Oh ok, mem_limit must be defined for amazon-ecs.
I have the same issue and I'm still looking for a solution. And so.. I think you should choose another instance type. For example: more than t2.micro (there is limited resources in the type).
The default value is 512 MB. Also, ecs-cli compose seems to require that mem_limit is written in bytes. So for 128 MB, write
mem_limit: 134217728
I'm setting mem_limit, but the error still won't go away. What else could cause this?
@dannymcpherson Do you have sufficient memory available on your container instances? Try reducing the mem_limit value, and see if that works.
I had the error Encountered error starting new ECS task: { "failures": [ { "reason": "RESOURCE:MEMORY", "arn": "arn:aws:ecs:us-east-1:xxxxxxxxxxxx:container-instance/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } ], "tasks": [] } from trying to run an elastic beanstalk app. Turned out this was because the sum of the memory I allocated for each container was > the memory of the EC2 box.
Also might be useful: https://rossfairbanks.com/2015/03/31/hello-world-in-ec2-container-service.html
I discovered the other day that my EB config was set to t1.micro instead of t2.micro, which is why I didn't have the 1 GB that I thought I had. You might want to double-check your config against the specs on https://aws.amazon.com/ec2/instance-types/
eb ssh then sudo docker stats will tell you how much memory each container is using.
That was my problem @jborrey. For future readers, without specifying a mem_limit on my docker-compose file, ecs defaulted to 512MB for each containers, and my docker-compose consists of 3 containers, so it ended up declaring 1.5GB of RAM. That amount of RAM was not available on a t2.micro instance, hence the error message. Then I set limits on my containers and ended up with my MYSQL service crashing with ~300MB. Still investigating if this is normal consumption for MYSQL, but in the meantime I think I'll need a more powerful instance.
You can also specify the mem_limit in kilobytes. Like this:
mem_limit: 3576492k
This problem was driving me crazy. Thanky the lordy for this thread. 🙏
I fixed it inthe task definition .json file
{
"family": "..",
"containerDefinitions": [
{
"name": "..",
"image": "...",
"cpu": 1,
"memory": 500, # Set this to whatever in MB
I was facing this problem with RESOURCE:MEMORY and I couldn't figure out why my mem_limit parameter was not being picked up by ecs-cli however I found out that my file format missed the task_definition key, so make sure you specify it:
Wrong:
version: "3"
services:
judge-server:
mem_limit: "128m"
oj-backend:
mem_limit: "128m"
Right:
version: "3"
task_definition: # <==== Services must be defined under task_definition key
services:
judge-server:
mem_limit: "128m"
oj-backend:
mem_limit: "128m"
I still have this issue, and I cannot figure out why it's failing for me.
I want to run 3 docker containers in one EB environment, on t2.medium instances.
Dockerrun.aws.json:
{
"AWSEBDockerrunVersion": 2,
"containerDefinitions": [
{
"name": "web-app",
"image": "...",
"command": [...],
"essential": true,
"memory": 1000,
"mountPoints": [...]
},
{
"name": "channels-app",
"image": "...",
"command": [...],
"essential": true,
"memory": 1000,
"mountPoints": [...]
},
{
"name": "nginx",
"image": "...",
"command": [...],
"essential": true,
"memory": 500,
"mountPoints": [...]
}
]
}
So 1G+1G+500M = 2.5G of memory. I ssh'ed into the allocated t2.medium instance, and there is enough free memory available: MemFree: 3518368 kB (3.5G).
Why do I still get the error every time?
Encountered error starting new ECS task: {
"failures": [
{
"reason": "RESOURCE:MEMORY",
"arn": "arn:aws:ecs:eu-central-1:XXX:container-instance/XXX"
}
],
"tasks": []
}
I tried running with t2.large, that works. But it's too expensive, and medium should be enough!
This took me many days to figure out, so for everyone with the same issue:
Check your deployed app! Apparently eb cli ignores all uncommited changes when working in a git repo. I was permanently changing parameters, running eb deploy, but did not notice that the zip file generated did not include the changes. Only the last commit in your current branch will be deployed!
TL;DR: My old config was deployed to eb and all changes I tried for fixing did not stick.
Even I am facing the same issue. I am triggering ECSOperator() tasks from Airflow ie. ECS tasks are triggered from Airflow. What I noticed is when ever a ECS task failed with this error, the Airflow CPU and Memory utilisation peaks up. And also I don't see any exceptions in CloudWatch pertaining to the RESOURCE:MEMORY. Is this memory issue related to Airflow or the ECS container where the task is running ?
memory
yeah this is what worked I was using a t2 micro instance and the limits in my task were way more than I had in the instance so I reduced it and it worked