16
votes

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?

2
Solved by Michal R.: the problem was, missing entry point parameter, which caused AWS to report confusing error. Fix is, either add sh,-c as entry point, or split the command. Waiting for Michal to publish his response so that he can get the credit. - Petr Kozelka
Do you mean add ENTRYPOINT ["sh", "-c"] to the Dockerfile? Can you elaborate some more on this answer? - ermalsh
@MadeInAlb no that's not it... I mean, in the container definition (within task definition), explicitly specify Entry point: ["sh","-c"]. But maybe putting this in dockerfile instead would work too, didn't try yet - Petr Kozelka
what if I have already entrypoint in my docker file? - kamiseq
@kamiseq it'll override that entrypoint. - marianogg9

2 Answers

12
votes

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

4
votes

It could be a problem with the entry point as pointed in the comments of the question (in the task definition) Entrypoint: ["sh","-c"]

It could also be a bad reference, for example a wrong log group in the LogConfiguration or something similar.