简体   繁体   中英

How to set docker labels on ECS agent container?

In a AWS ECS cluster each cluster instance runs the ecs-agent [1] as a docker container. Next to that container I run datadog-agent [2] also as a container. The datadog-agent monitors all other containers and ship their logs to DataDog. In order to have the log of each container tagged by name I've added a specific docker label [3] to each container with the respective name. However, I'm not been able to add a docker label to the ecs-agent itself.

Is there a way to add custom docker labels to the ecs-agent container?

[1] - https://github.com/aws/amazon-ecs-agent

[2] - https://github.com/DataDog/datadog-agent

[3] - https://docs.datadoghq.com/logs/log_collection/docker/

How are you spinning up ecs-agent container? What is docker run command?. Did you try like below?.

sudo docker run --name ecs-agent \
--detach=true \
--restart=on-failure:10 \
--volume=/var/run:/var/run \
--volume=/var/log/ecs/:/log \
--volume=/var/lib/ecs/data:/data \
--volume=/etc/ecs:/etc/ecs \
--net=host \
--env-file=/etc/ecs/ecs.config \
--label=myLabelName=amazon-ecs-agent \
amazon/amazon-ecs-agent:latest

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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