[英]Showing docker container log in aws ECS cluster
I have trouble showing log from my docker container in ecs. 我无法在ecs中显示来自我的docker容器的日志。
What I did: 我做了什么:
1) ssh into an ec2 instance of the cluster. 1)ssh进入集群的ec2实例。
2) docker logs my service 2)码头工人记录我的服务
Then this message is showing up: 然后显示此消息:
FATA[0000] Error executing 'logs': Failed to get log configuration: Container 'my-container': Must specify log driver as awslogs
What I am trying to do is to show log in the console. 我想做的是在控制台中显示日志。
What I don't understand is that for some container, the command docker logs works fine. 我不明白的是,对于某些容器,docker日志命令可以正常工作。
open docker daemon file in /etc/docker/daemon.json
and add log driver: 在/etc/docker/daemon.json
打开/etc/docker/daemon.json
daemon文件并添加日志驱动程序:
{
"log-driver": "awslogs"
}
and restart docker with sudo systemctl restart docker
并使用sudo systemctl restart docker
You should choose the docker log driver to json-log
while creating the task definition revision in ECS, If you want to see the docker logs with docker logs container-id
command. 在ECS中创建任务定义修订版时,应选择docker log driver为json-log
,如果要使用docker logs container-id
命令查看Docker日志。 you will get the container id from the docker ps command. 您将从docker ps命令获取容器ID。
But if you want to push docker logs to cloudwatch logs then you have to choose aws-logs
as docker log driver. 但是,如果要将docker日志推送到cloudwatch日志,则必须选择aws-logs
作为docker日志驱动程序。
For some containers, it might work fine because those have docker log driver as json-file set in their task definition. 对于某些容器,它可能工作正常,因为那些容器在其任务定义中将docker log driver作为json-file设置。
How to create a task definition? 如何创建任务定义? Reference: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-task-definition.html 参考: https : //docs.aws.amazon.com/AmazonECS/latest/developerguide/create-task-definition.html
Do let me know if you are still facing the issue. 如果您仍然遇到问题,请告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.