簡體   English   中英

如何在 docker 容器內運行 AWS CW 代理?

[英]How to run AWS CW Agent inside docker container?

我一直在嘗試在容器內運行 CW 代理但失敗了。 錯誤“未知的初始化系統”

我知道 docker 日志驅動程序,但如果可能,我會嘗試使用 aws 代理。

您可以使用 Amazon ECS 容器代理。

Amazon ECS 容器代理允許容器實例連接到您的集群。 Amazon ECS 容器代理包含在 Amazon ECS-optimized AMI 中,但您也可以將其安裝在任何支持 Amazon ECS 規范的 Amazon EC2 實例上。 Amazon ECS 容器代理僅在 Amazon EC2 實例上受支持。

安裝 Amazon ECS 容器代理

在運行 init 命令之前,請確保 ec2 實例具有允許訪問 ECS 的 IAM 角色

您可以使用 AWS 雲監視代理docker ,這是官方的docker鏡像amazon/cloudwatch-agent

docker run -it --rm amazon/cloudwatch-agent

https://hub.docker.com/r/amazon/cloudwatch-agent

構建您自己的 CloudWatch 代理 Docker 映像

您可以通過參考位於https://github.com/aws-samples/amazon-cloudwatch-container-insights/blob/master/cloudwatch-agent-dockerfile/Dockerfile的 Dockerfile 來構建自己的 CloudWatch 代理 Docker 映像。

FROM debian:latest as build

RUN apt-get update &&  \
    apt-get install -y ca-certificates curl && \
    rm -rf /var/lib/apt/lists/*

RUN curl -O https://s3.amazonaws.com/amazoncloudwatch-agent/debian/amd64/latest/amazon-cloudwatch-agent.deb && \
    dpkg -i -E amazon-cloudwatch-agent.deb && \
    rm -rf /tmp/* && \
    rm -rf /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard && \
    rm -rf /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl && \
    rm -rf /opt/aws/amazon-cloudwatch-agent/bin/config-downloader

FROM scratch

COPY --from=build /tmp /tmp

COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt

COPY --from=build /opt/aws/amazon-cloudwatch-agent /opt/aws/amazon-cloudwatch-agent

ENV RUN_IN_CONTAINER="True"
ENTRYPOINT ["/opt/aws/amazon-cloudwatch-agent/bin/start-amazon-cloudwatch-agent"]

ContainerInsights-build-docker-image

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM