title: How to run docker task with Amazon ECS - getting error `STOPPED (CannotStartContainerError: Error response from dae)`
body: <p>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.</p>
  
  <p>So I decided to follow the guide in <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-task-definition.html" rel="noreferrer">https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-task-definition.html</a>
  and use the "ping" example - it should just ping a domain couple of times, and stop.</p>
  
  <p>The problem is, I always receive this message in the task status:</p>
  
  <pre><code>STOPPED (CannotStartContainerError: Error response from dae)
  </code></pre>
  
  <p>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.</p>
  
  <p>I even tried it on a fresh new AWS account, using these steps:</p>
  
  <ul>
  <li>in <a href="https://us-east-2.console.aws.amazon.com/ecs/" rel="noreferrer">https://us-east-2.console.aws.amazon.com/ecs/</a> created new cluster (networking only)</li>
  <li>in task definitions, created a taskdef
  
  <ul>
  <li>with docker image <code>alpine:latest</code>, command <code>ping -c 4 google.com</code></li>
  </ul></li>
  <li>then I select the cluster, switch to "tasks" tab, and enter the run dialog
  
  <ul>
  <li>with one of pre-created subnets</li>
  </ul></li>
  </ul>
  
  <p>After executing:</p>
  
  <ul>
  <li>the task appears in the cluster's tasks list in PENDING state</li>
  <li>it takes couple of minutes</li>
  <li>eventually (using refresh button), it changes to the mentioned message - <code>STOPPED (CannotStartContainerError: Error response from dae)</code></li>
  </ul>
  
  <p>My guess is that the reason is:</p>
  
  <ul>
  <li>either the task cannot download the image</li>
  <li>or the instance cannot reach outside net</li>
  </ul>
  
  <p>What can I be doing wrong? How to fix?</p>