Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run docker task with Amazon ECS - getting error `STOPPED (CannotStartContainerError: Error response from dae)`

My goal is to execute a benchmark deployed as a docker image. While doing so, I had too many issues, so I decided to first make something extremely trivial work.

So I decided to follow the guide in https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-task-definition.html and use the "ping" example - it should just ping a domain couple of times, and stop.

The problem is, I always receive this message in the task status:

STOPPED (CannotStartContainerError: Error response from dae)

I tried it with various subnets and security groups, but the result is always the same - the task starts, and after a minute or two fails with the message above.

I even tried it on a fresh new AWS account, using these steps:

  • in https://us-east-2.console.aws.amazon.com/ecs/ created new cluster (networking only)
  • in task definitions, created a taskdef
    • with docker image alpine:latest, command ping -c 4 google.com
  • then I select the cluster, switch to "tasks" tab, and enter the run dialog
    • with one of pre-created subnets

After executing:

  • the task appears in the cluster's tasks list in PENDING state
  • it takes couple of minutes
  • eventually (using refresh button), it changes to the mentioned message - STOPPED (CannotStartContainerError: Error response from dae)

My guess is that the reason is:

  • either the task cannot download the image
  • or the instance cannot reach outside net

What can I be doing wrong? How to fix?

like image 568
Petr Kozelka Avatar asked Oct 14 '19 12:10

Petr Kozelka


People also ask

Why is my ECS task stopped?

The most common reasons are: Essential container exited. Failed Elastic Load Balancing (ELB) health checks. Failed container health checks.

What is responsible for starting and stopping tasks on an ECS container instance?

Q: What is responsible for starting and stopping tasks on an ECS Container instance. E: The ECS Agent is responsible for starting/stopping tasks. It also monitors tasks and resource utilization.


1 Answers

In my case too the log group was the problem. The one I had configured wasnt working. Hence I enabled the "Auto-configure CloudWatch Logs" option in the "Log Configuration" of the container settings.

Also if you open the stopped task, navigate to the container section, expand it, under the Details section you can see a detailed error message. Screenshot below

How to see the error details

like image 162
Harshad Vyawahare Avatar answered Sep 16 '22 22:09

Harshad Vyawahare