How do I capture the console output for a container launched on ECS?
Asked Answered
A

4

13

When I launch a container using docker run the command prompt shows a lot of useful information that's invaluable while debugging.

Is there a mechanism is ECS that allows me to capture this information? At the moment, I'm SSH'ing into the container and launching containers manually to debug them, which is not ideal.

Adowa answered 18/1, 2017 at 11:46 Comment(0)
G
7

Yep. You can use CloudWatch Logs in combination with ECS. It does require a bit more setup, but once done all container logs will be streamed into CloudWatch Logs which means it can be viewed from the AWS console.

General CloudWatch Log integration with ECS is explained here. Using the awslogs Driver as part of your task definitions is explained in more detail here.

Hope that helps.

Germ answered 18/1, 2017 at 11:57 Comment(2)
I've chosen this as the accepted answer because, following this example, I was able to achieve exactly what I wanted on my first attempt.Adowa
@LiamM do you remember how you configured the dockerfile to do this. I simply have it running bash and calling a script that does an echo yet nothing appears in logsJesuit
C
1

You can also use fluentd log driver.

For more details in here: http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#container_definition_storage

Clockmaker answered 18/1, 2017 at 14:8 Comment(0)
R
0

you can use this pypi package to check a specific task logs.

https://pypi.org/project/dokr/

Install using pip & install ecs-cli

pip install dokr

install ecs-cli from here

Check logs using

dokr ecs log

Check this screenshot

enter image description here

PS: I am the author of this package. If you find any issue. Please raise it on github

Rashidarashidi answered 26/9, 2018 at 3:58 Comment(0)
S
0

The simplest way is to use the "awslogs" docker log driver.

If running straight up docker, add this to daemon.json:

{
  "log-driver": "awslogs",
  "log-opts": {
    "awslogs-region": "us-east-1"
  }
}

If you're using docker compose, configure the logging like in this example:

myservice:
  logging:
    driver: awslogs
    options:
      awslogs-region: us-east-1

You will need to set up your AWS credentials.

See https://docs.docker.com/config/containers/logging/awslogs/ for details.

Sheply answered 15/7 at 17:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.