40

I am trying to configure my docker hub image with aws ecs..I have created repository, cluster, and task while running task am getting an error as an essential container in task exited 1. while trying to get exact error details I have found that some of my variables are shown as not configured.

find the screenshot attached of errors.

cluster details error detail

Lin Du
  • 88,126
  • 95
  • 281
  • 483
Chirag
  • 408
  • 1
  • 4
  • 8
  • Your container is just dying. Run it locally on your machine to see what's happening or change the code to make your container print logs to stdout and look at the logs tab on the task. – Webert Lima Apr 16 '19 at 07:34
  • Does your instance have access to internet? Also, it is always better to configure cloud watch where you can see the logs in details. – bot Apr 16 '19 at 14:03

4 Answers4

32

You should setup the "Log Configuration" by specifying a log configuration in your task definition. I would recommend the awslogs configuration type, as this lets you see the logs from your container right inside the console.

Once you do that you will get a new tab on the task details screen called "Logs" and you can click that to see the output from your container as it was starting up. You will probably see some kind of error or crash as the "Essential container exited" error means that the container was expected to stay up and running, but it just exited.

nathanpeck
  • 4,608
  • 1
  • 20
  • 18
4

I had to expand the corresponding container details in the stopped task and check the "Details" --> "Status reason", which revealed the following issue:

OutOfMemoryError: Container killed due to memory usage Exit Code 137

After increasing the available container memory, it worked fine.

moritz.vieli
  • 1,747
  • 1
  • 14
  • 17
  • could you be more specific, where do you find the container details in the `Amazon ECS` page? Only options are `Clusters, Task Definition, Account settings, Clusters, Repositories` – Bersan Nov 25 '22 at 23:05
  • @Bersan You have to open the corresponding cluster, open the stopped task and go from there (expand the container, etc.). – moritz.vieli Nov 28 '22 at 18:38
  • Look at the bottom for "hidden" extra features ... "sidebar" at the bottom. – Joeri Dec 01 '22 at 14:33
0

I had a similar issue. You can setup the cloudwatch log, there you can get the full error log which will help you to debug and fix the issue. below are the part of the taken taken from aws official documentation.

Using the auto-configuration feature to create a log group

When registering a task definition in the Amazon ECS console, you have the option to allow Amazon ECS to auto-configure your CloudWatch logs. This option creates a log group on your behalf using the task definition family name with ecs as the prefix.

To use log group auto-configuration option in the Amazon ECS console

  1. Open the Amazon ECS console at https://console.aws.amazon.com/ecs/.

  2. In the left navigation pane, choose Task Definitions, Create a new Task Definition, alternatively, you can also do create a revision of the exiting task definition.

  3. Select your compatibility option and choose Next Step.

  4. Choose Add container.

  5. In the Storage and Logging section, for Log configuration, choose Auto-configure CloudWatch Logs.

  6. Enter your awslogs log driver options. For more information, see Specifying a log configuration in your task definition.

Complete the rest of the task definition wizard.

bSr
  • 1,410
  • 3
  • 16
  • 30
0

I have been stuck on the same error.

The problem ended up being "Task tagging configuration" > DISABLE "Enable ECS managed tags"

When this parameter is enabled, Amazon ECS automatically tags your tasks with two tags corresponding to the cluster and service names. These tags allow you to identify tasks easily in your AWS Cost and Usage Report.

Billing permissions are separate and not by default assigned when you create a new ECS cluster and task definition with the default setting. This is why ECS was failing with "STOPPED: Essential container in task exited"