如何捕获在 ECS 上启动的容器的控制台输出?

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

当我使用 docker run 启动容器时,命令提示符会显示很多有用的信息,这些信息在调试时非常宝贵。

ECS 是否有一种机制可以让我捕获这些信息?目前,我正在通过 SSH 连接到容器并手动启动容器来调试它们,这并不理想。

是的。您可以将 CloudWatch Logs 与 ECS 结合使用。它确实需要多一点设置,但完成后所有容器日志都将流式传输到 CloudWatch Logs,这意味着可以从 AWS 控制台查看它。

解释了 CloudWatch Log 与 ECS 的一般集成here. Using the awslogs Driver as part of your task definitions is explained in more detail here

希望对您有所帮助。

您也可以使用 fluentd 日志驱动程序。

详情请见此处: http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#container_definition_storage

您可以使用这个 pypi 包来检查特定的任务日志。

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

使用 pip 安装并安装 ecs-cli

pip install dokr

here 安装 ecs-cli

使用

检查日志
dokr ecs log

查看此屏幕截图

PS: 我是这个包的作者。如果您发现任何问题。请在 github

提出