How can I get logs of my task failed container

0

I am using docker compose to run my ecs fargate service, and got error AggregatorService TaskFailedToStart: Task failed to start.

How can I get logs of my service and know why task failed?

質問済み 2年前9469ビュー
2回答
0
承認された回答

So you might want to check whether the log group was created and deleted as the service tasks failed to start. If the log group is created as part of the deployment in CFN, it might just have been deleted as it rolled back.

Best way to figure out what's happened is to go to ECS -> cluster -> services -> Tasks. There, once you see your task pending, click on it. Expand the container, and you will be able to find a shortcut link to the container's log stream. Equally you will be able to see the exit code. If your app in docker failed before doing any logging, which is possible, then you can figure that out with the exit code (most likely, exit !=0).

You could "patch" your dockerfile or entrypoint to print out "Hello, I am starting" right before your main app starts. That will tell you whether the task failed because of your app or due to something else, i.e, lack of permissions / wrong image .. etc.

If you want to generate the CFN templates for your services to be deployed so that you can have a look into it and possibly tweak things, try out ECS Compose-X. Achieves the same thing as the docker ecs plugin, but does it in a very different way and has lots of different features. Either way, hope the guidelines above help.

profile picture
回答済み 2年前
  • Yes, I should not test in the docker compose file. I should test in the ecs cluster manually first.

0

Hello,

You should be able to get logs for ECS in CloudWatch if you have logging setup in Container Definition. Please refer to https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_awslogs.html for using awslogs driver to log into CloudWatch.

For error codes related to ECS, please see https://docs.aws.amazon.com/AmazonECS/latest/userguide/stopped-task-error-codes.html for more information.

Thank you.

Regards,
Franky

AWS
回答済み 2年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ