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?

preguntada hace 2 años9478 visualizaciones
2 Respuestas
0
Respuesta aceptada

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
respondido hace 2 años
  • 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
respondido hace 2 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas