-1

我目前正在尝试为 AWS 批处理构建自定义 ubuntu ami,并遵循此处提到的文档 https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-install.html

但是,当我尝试在该机器上启动 docker 代理时,它总是不断给我这个错误

2018-07-04T23:34:01Z [INFO] Amazon ECS agent Version: 1.18.0, Commit: c0defea9
2018-07-04T23:34:01Z [INFO] Loading state! module="statemanager"
2018-07-04T23:34:01Z [INFO] Event stream ContainerChange start listening...
2018-07-04T23:34:01Z [INFO] Creating root ecs cgroup: /ecs
2018-07-04T23:34:01Z [INFO] Creating cgroup /ecs
2018-07-04T23:34:01Z [WARN] Disabling TaskCPUMemLimit because agent is unabled to setup '/ecs' cgroup: cgroup create: unable to create controller: mkdir /sys/fs/cgroup/systemd/ecs: read-only file system
2018-07-04T23:34:01Z [WARN] Error getting valid credentials (AKID ): NoCredentialProviders: no valid providers in chain. Deprecated.
    For verbose messaging see aws.Config.CredentialsChainVerboseErrors
2018-07-04T23:34:01Z [INFO] Registering Instance with ECS
2018-07-04T23:34:01Z [ERROR] Could not register: NoCredentialProviders: no valid providers in chain. Deprecated.
    For verbose messaging see aws.Config.CredentialsChainVerboseErrors
2018-07-04T23:34:01Z [ERROR] Error registering: NoCredentialProviders: no valid providers in chain. Deprecated.
For verbose messaging see aws.Config.CredentialsChainVerboseErrors

我确保该实例具有与之关联的 ecsInstanceRole。你们能告诉我我错过了什么吗?

4

2 回答 2

1

不确定您是如何启动 ecs-agent 的。遇到了错误

Disabling TaskCPUMemLimit because agent is unabled to setup '/ecs cgroup: cgroup create: unable to create controller: /sys/fs/cgroup/systemd/ecs: read-only file system

我们通过将卷添加--volume=/sys/fs/cgroup:/sys/fs/cgroup:ro到我们启动 ecs 的 systemd 单元文件来解决这个问题。

除此之外,我认为问题出在ecsInstanceRole. 您可以验证它具有以下权限吗?AmazonEC2ContainerRegistryFullAccess, AmazonEC2ContainerServiceFullAccess,AmazonEC2ContainerServiceforEC2Role

以下是 ecs-agent 的完整 systemd 文件。

[Unit]
Description=Docker Container %I
Requires=docker.service
After=docker.service

[Service]
Restart=always
ExecStartPre=-/usr/bin/docker rm -f %i
ExecStart=/usr/bin/docker run --name %i \
--restart=on-failure:10 \
--volume=/var/run:/var/run \
--volume=/var/log/ecs/:/log:Z \
--volume=/var/lib/ecs/data:/data:Z \
--volume=/etc/ecs:/etc/ecs \
--volume=/sys/fs/cgroup:/sys/fs/cgroup:ro \
--net=host \
--env-file=/etc/ecs/ecs.config \
--env LOGSPOUT=ignore \
amazon/amazon-ecs-agent:latest
ExecStop=/usr/bin/docker stop %i

[Install]
WantedBy=default.target
于 2018-07-26T19:50:19.023 回答
0

我遇到了同样的消息。您需要根据此文档创建 IAM 角色并使用该角色启动实例:https ://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_container_instance.html

于 2019-01-18T17:17:08.413 回答