41

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

2
  • 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. Apr 16, 2019 at 7: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, 2019 at 14:03

4 Answers 4

33

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.

3
  • Thank you for your answer, helped me a lot :)
    – d3vpasha
    Apr 20, 2021 at 18:29
  • 4
    Thanks @nathanpeck. My error was "standard_init_linux.go:219: exec user process caused: exec format error" because I was building docker images on Apple Silicon M1 and pushing it in ECR. Jul 23, 2021 at 19:08
  • @ShahrearBinAmin Yes, it's exactly the same problem I got! Thanks for sharing.
    – Carl Tsai
    Apr 15 at 16:09
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.

3
  • 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, 2022 at 23:05
  • @Bersan You have to open the corresponding cluster, open the stopped task and go from there (expand the container, etc.). Nov 28, 2022 at 18:38
  • Look at the bottom for "hidden" extra features ... "sidebar" at the bottom.
    – Joeri
    Dec 1, 2022 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.

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"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.