Vic
Vic

Reputation: 645

resource:memory error when trying to run an ECS task using AWS CLI

I'm trying to set up CI with AWS ECS and docker. I use Codeship as a CI tool, but that should not really matter much.

I do the following steps in a shell script:

Shell script runs successfully, however I see an error in output after I try to run my ECS task:

{
    "tasks": [],
    "failures": [
        {
            "arn": "arn:aws:ecs:us-east-2:99999999999:container-instance/050ab165-7669-45d5-8be7-d990cf4fff42",
            "reason": "RESOURCE:MEMORY"
        }
    ]
}

my ecs-task-def.json:

{
  "containerDefinitions": [
    {
      "name": "postgraphile-container",
      "image": "999999999999.dkr.ecr.us-east-2.amazonaws.com/test-repository",
      "memory": 500,
      "essential": true,
      "portMappings": [
        {
          "hostPort": 5000,
          "containerPort": 5000
        }
      ]
    }
  ],
  "volumes": [],
  "memory": "900",
  "cpu": "128",
  "placementConstraints": [],
  "family": "postgraphile",
  "taskRoleArn": ""
}

I think I already checked all the memory limits.. am I missing anything?

UPDATE: After couple of reboots of ec2 instance I can finally run the ecs task with no errors. After running task several times, the error returns

Upvotes: 27

Views: 20130

Answers (3)

palvarez
palvarez

Reputation: 1598

There are limited values accepted for CPU and memory. Check the docs for the supported values:

CPU value Memory value (MiB)
256 (.25 vCPU) 512 (0.5GB), 1024 (1GB), 2048 (2GB)
512 (.5 vCPU) 1024 (1GB), 2048 (2GB), 3072 (3GB), 4096 (4GB)
1024 (1 vCPU) 2048 (2GB), 3072 (3GB), 4096 (4GB), 5120 (5GB), 6144 (6GB), 7168 (7GB), 8192 (8GB)
2048 (2 vCPU) Between 4096 (4GB) and 16384 (16GB) in increments of 1024 (1GB)
4096 (4 vCPU) Between 8192 (8GB) and 30720 (30GB) in increments of 1024 (1GB)

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html

Upvotes: 1

Sajin Pattath
Sajin Pattath

Reputation: 311

I had faced similar error while deploying services to EC2 using docker. I was using putty not CLI. I ran command docker images to get the size of each image. I found total size was more than my EC2 instance storage. I increased the EC2 instance volume to 20GB (EC2-->Volume-->Modify volume). Issue was resolved. Later I faced issue again after multiple trial and error. This time, I found I had lot of unused images which got accumulated after multiple docker compose commands. I removed all the containers, volumes and images and memory error was resolved.

Upvotes: 0

abhijain
abhijain

Reputation: 11

I was getting this error when deploying a service on an ECS cluster. Removing the service completely and then redeploying it afresh helped me resolve this issue.

Upvotes: 0

Related Questions