从Docker容器loginAWS Cloudwatch

在AWS EC2实例中,我有几个docker-compose运行的docker容器。 我正在寻找将日志发送到AWS CloudWatch。 我还遇到了从运行Sierra的Mac中将日志从Docker容器转移到AWS CloudWatch的问题,因此我转移到了运行Amazon AMI的EC2实例。

我的docker – 撰写文件:

version: '2' services: scraper: build: ./Scraper/ logging: driver: "awslogs" options: awslogs-region: "eu-west-1" awslogs-group: "permission-logs" awslogs-stream: "stream" volumes: - ./Scraper/spiders:/spiders 

当我运行docker-compose时,出现以下错误:

scraper_1 | 警告:“awslogs”日志驱动程序没有可用的日志

但容器正在运行。 AWS CloudWatchstream中不显示任何日志。 我已经为Docker容器运行的EC2容器分配了一个IAMangular色。

我现在完全不知道该怎么做,并且会提出任何build议。

awslogs工作不使用ECS。

您需要configurationAWS凭证(用户应具有适当的IAMangular色[cloudwatch logs])。

我使用这个教程,它为我工作: https : //wdullaer.com/blog/2016/02/28/pass-credentials-to-the-awslogs-docker-logging-driver-on-ubuntu/

您正在使用awslogs的AWS日志驱动程序用于EC2容器服务(ECS)。 它不会在普通的EC2上工作。 见文件 。

我会build议创build一个单节点ECS群集 。 确保该群集中的EC2实例具有angular色,并且该angular色提供了写入Cloudwatch日志的权限。

从那里你的容器中的任何东西都logging到stdout将被awslogs驱动程序捕获并stream入Cloudwatch日志。