如何在Elastic Beanstalk多容器docker上使用fluentd日志驱动程序
我试图用下面的Dockerrun.aws.json来使用fluentd日志驱动程序,
{ “AWSEBDockerrunVersion”:2, “containerDefinitions”:[ { “name”:“apache”, “image”:“php:5.6-apache”, “必不可less”:真, “记忆”:128, “portMappings”:[ { “hostPort”:80, “containerPort”:80 } ] “logConfiguration”:{ “logDriver”:“fluentd”, “选项”:{ “fluentd-address”:“127.0.0.1:24224” } } } ] }
但发生以下错误。
ERROR: Encountered error starting new ECS task: {cancel the command. "failures": [ { "reason": "ATTRIBUTE", "arn": "arn:aws:ecs:ap-northeast-1:000000000000:container-instance/00000000-0000-0000-0000-000000000000" } ], "tasks": [] } ERROR: Failed to start ECS task after retrying 2 times. ERROR: [Instance: i-00000000] Command failed on instance. Return code: 1 Output: beanstalk/hooks/appdeploy/enact/03start-task.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
我应该configuration什么?
似乎您也可以在您的应用程序环境目录中使用.ebextensions/01-fluentd.config
文件来完成它, .ebextensions/01-fluentd.config
带有以下内容:
files: "/home/ec2-user/setup-available-log-dirvers.sh": mode: "000755" owner: root group: root content: | #!/bin/sh set -e if ! grep fluentd /etc/ecs/ecs.config &> /dev/null then echo 'ECS_AVAILABLE_LOGGING_DRIVERS=["json-file","syslog","fluentd"]' >> /etc/ecs/ecs.config fi container_commands: 01-configure-fluentd: command: /home/ec2-user/setup-available-log-dirvers.sh
现在你必须部署一个新的应用程序版本(没有stream畅的configuration),重build你的环境,添加stream畅的configuration:
logConfiguration: logDriver: fluentd options: fluentd-address: localhost:24224 fluentd-tag: docker.myapp
现在部署更新的应用程序,一切都应该现在工作。
我自己解决了这个问题。
首先,我准备一个具有以下用户数据的自定义ami。
#cloud-config repo_releasever: 2015.09 repo_upgrade: none runcmd: - echo 'ECS_AVAILABLE_LOGGING_DRIVERS=["json-file","syslog","fluentd"]' >> /etc/ecs/ecs.config
其次,我定义了在我的环境EC2设置中创build自定义ami的ami id。 最后,我将我的应用程序部署到Elastic Beanstalk。 在此之后,我的环境中stream利的日志驱动程序正常工作。
为了在Elastic Beanstalk多ECS_AVAILABLE_LOGGING_DRIVERS
Docker中使用fluentd日志驱动程序,需要在/etc/ecs/ecs.config
定义ECS_AVAILABLE_LOGGING_DRIVERS
variables。 Elastic Beanstalk多容器Docker在内部使用ECS,因此相关设置位于ECS文档中。 请阅读以下文档中的logConfiguration
部分: http : logConfiguration
我已经给已经接受的答案添加了一个评论,只是添加了我用来使它为我工作的完整的ebextension文件
files: "/home/ec2-user/setup-available-log-dirvers.sh": mode: "000755" owner: root group: root content: | #!/bin/sh set -e if ! grep fluentd /etc/ecs/ecs.config &> /dev/null then echo 'ECS_AVAILABLE_LOGGING_DRIVERS=["json-file","syslog","fluentd"]' >> /etc/ecs/ecs.config fi container_commands: 00-configure-fluentd: command: /home/ec2-user/setup-available-log-dirvers.sh 01-stop-ecs: command: stop ecs 02-stop-ecs: command: start ecs
设置日志驱动程序后,我们只是重新设置ecs
- 弹性beanstalk泊坞窗应用程序无法连接到MySQL
- Docker部署失败的Elastic Beanstalk
- 对于Web应用程序,为模板和api服务器分配两个容器是否有意义?
- 在Dockerrun.aws.json中做什么“日志logging”?
- 使用AWS Application Load Balancer的Websocket超时
- 运行多容器Docker的AWS BeanStalk环境无法启动Health:Severe
- 我如何将一个NodeJS应用绑定到在AWS上的Docker容器中运行的MongoDB?
- 如何连接AWS ElasticBeanstalk中的多个Docker容器?
- 用于服务HTTP / HTTPS请求的Beanstalk-Dockerconfiguration问题