简体   繁体   English

AWS ecs任务定义变量

[英]AWS ecs task definition variables

Is it possible to dynamically set values in AWS ECS task definitions? 是否可以在AWS ECS任务定义中动态设置值? For example. 例如。 I have the following volume definition. 我有以下体积定义。

"volumes": [
    {
        "host": {
            "sourcePath": "/tmp/logs/registrations"
        },
        "name": "logs"
    }
],

I would like do do something like /tmp/logs/<container_id> . 我想做类似/tmp/logs/<container_id>事情。

I am trying to do this because I have multiple containers running the same app. 我正在尝试执行此操作,因为我有多个运行同一应用程序的容器。 I need to mount each containers log directory for a sumologic collector. 我需要为摘要收集器安装每个容器日志目录。 The problem is if the directories aren't namespaced by container then the mounts will conflict. 问题是,如果目录不是由容器命名的,则挂载将发生冲突。

Cloudwatch logs is another option if saving to the file system is not a requirement. 如果不需要保存到文件系统,则Cloudwatch日志是另一种选择。

If you are using the ECS optimized AMI it's already configured and all you need to do is turn it on in the container task definition: 如果您使用的是ECS优化的AMI,则已经对其进行了配置,只需在容器任务定义中将其打开即可:

http://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_awslogs.html http://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_awslogs.html

You would also need to configure log groups or log streams for each container. 您还需要为每个容器配置日志组或日志流。

Is saving logs to the file system a hard requirement? 将日志保存到文件系统是否很困难? If not, Sumo Logic has a pretty good article about another option: Update On Logging With Docker . 如果不是这样,Sumo Logic的一篇不错的文章介绍了另一个选择: 使用Docker更新日志

You run the Sumo Logic Collector for Docker in one container and your application in another. 您在一个容器中运行适用于DockerSumo Logic Collector,在另一个容器中运行应用程序。 You configure Docker to send logs from your application container to the Sumo Logic collector. 您可以配置Docker将日志从应用程序容器发送到Sumo Logic收集器。 This is built into Docker , so your application shouldn't need to change. 内置于Docker中 ,因此您的应用程序无需更改。 The collector container will then send those logs to Sumo Logic. 然后,收集器容器会将这些日志发送到Sumo Logic。

I've seen this pattern called the sidecar , in case you're looking for other examples of it. 我已经看过这种称为sidecar的模式,以防您在寻找其他示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM