![systemctl 启用 docker 容器服务 - 失败](https://linux22.com/image/157221/systemctl%20%E5%90%AF%E7%94%A8%20docker%20%E5%AE%B9%E5%99%A8%E6%9C%8D%E5%8A%A1%20-%20%E5%A4%B1%E8%B4%A5.png)
我基本上是按照AWS中的文档进行操作的https://docs.aws.amazon.com/AmazonECS/latest/developerguide/example_user_data_scripts.html
我创建了 Centos 7 并尝试在我的 EC2 实例中docker
安装。ese-agent
这是我的服务文件
/etc/systemd/system/docker_container_ecs_agent.service
[Unit]
Description=Docker Container %I
Requires=docker.service
After=docker.service
[Service]
Restart=always
ExecStartPre=-/usr/bin/docker rm -f ecs-agent
ExecStart=/usr/bin/docker run --name ecs-agent --privileged --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 --net=host --env-file=/etc/ecs/ecs.config amazon/amazon-ecs-agent:latest
ExecStop=/usr/bin/docker stop ecs-agent
[Install]
WantedBy=default.target
我也做了enable
andstart
命令
sudo systemctl enable docker_container_ecs_agent.service
Created symlink from /etc/systemd/system/default.target.wants/docker_container_ecs_agent.service to /etc/systemd/system/docker_container_ecs_agent.service.
sudo systemctl start docker_container_ecs_agent.service
但是,当我通过输入检查状态时systemctl
,它抛出了失败状态。
UNIT LOAD ACTIVE SUB DESCRIPTION
docker_container_ecs_agent.service loaded failed failed docker_container_ecs_agent.service
更新错误日志
systemctl status docker_container_ecs_agent.service
● docker_container_ecs_agent.service - Docker Container ece-agent
Loaded: loaded (/etc/systemd/system/docker_container_ecs_agent.service; enabled; vendor preset: disabled)
Active: failed (Result: start-limit) since Mon 2019-07-15 16:43:59 UTC; 17s ago
Process: 17464 ExecStop=/usr/bin/docker stop ecs-agent (code=exited, status=0/SUCCESS)
Process: 17386 ExecStart=/usr/bin/docker run --name ecs-agent --privileged --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 --net=host --env-file=/etc/ecs/ecs.config amazon/amazon-ecs-agent:latest (code=exited, status=1/FAILURE)
Process: 17380 ExecStartPre=/usr/bin/docker rm -f ecs-agent (code=exited, status=0/SUCCESS)
Main PID: 17386 (code=exited, status=1/FAILURE)
systemd[1]: Unit docker_container_ecs_agent.service entered failed state.
systemd[1]: docker_container_ecs_agent.service failed.
systemd[1]: docker_container_ecs_agent.service holdoff time over, scheduling restart.
systemd[1]: Stopped Docker Container ece-agent.
systemd[1]: start request repeated too quickly for docker_container_ecs_agent.service
systemd[1]: Failed to start Docker Container ece-agent.
systemd[1]: Unit docker_container_ecs_agent.service entered failed state.
systemd[1]: docker_container_ecs_agent.service failed.
Update2-docker 日志
docker run --privileged=true --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 --net=host --env-file=/etc/ecs/ecs.config amazon/amazon-ecs-agent:latest
2019-07-15T19:57:44Z [INFO] Loading configuration
2019-07-15T19:57:44Z [INFO] Image excluded from cleanup: amazon/amazon-ecs-agent:latest
2019-07-15T19:57:44Z [INFO] Image excluded from cleanup: amazon/amazon-ecs-pause:0.1.0
2019-07-15T19:57:44Z [INFO] Amazon ECS agent Version: 1.29.1, Commit: f95f731b
2019-07-15T19:57:44Z [INFO] Unable to get Docker client for version 1.27: version detection using MinAPIVersion: unsupported version: 1.27
2019-07-15T19:57:44Z [INFO] Unable to get Docker client for version 1.28: version detection using MinAPIVersion: unsupported version: 1.28
2019-07-15T19:57:44Z [INFO] Unable to get Docker client for version 1.29: version detection using MinAPIVersion: unsupported version: 1.29
2019-07-15T19:57:44Z [INFO] Unable to get Docker client for version 1.30: version detection using MinAPIVersion: unsupported version: 1.30
2019-07-15T19:57:44Z [INFO] Unable to get Docker client for version 1.31: version detection using MinAPIVersion: unsupported version: 1.31
2019-07-15T19:57:44Z [INFO] Unable to get Docker client for version 1.32: version detection using MinAPIVersion: unsupported version: 1.32
2019-07-15T19:57:44Z [INFO] Creating root ecs cgroup: /ecs
2019-07-15T19:57:44Z [INFO] Creating cgroup /ecs
2019-07-15T19:57:44Z [INFO] Loading state! module="statemanager"
2019-07-15T19:57:44Z [INFO] Event stream ContainerChange start listening...
2019-07-15T19:57:44Z [WARN] Error getting valid credentials (AKID ): NoCredentialProviders: no valid providers in chain. Deprecated.
For verbose messaging see aws.Config.CredentialsChainVerboseErrors
2019-07-15T19:57:44Z [INFO] Registering Instance with ECS
2019-07-15T19:57:44Z [INFO] Remaining mem: 3787
2019-07-15T19:57:44Z [ERROR] Unable to register as a container instance with ECS: NoCredentialProviders: no valid providers in chain. Deprecated.
For verbose messaging see aws.Config.CredentialsChainVerboseErrors
2019-07-15T19:57:44Z [INFO] Remaining mem: 3787
2019-07-15T19:57:44Z [ERROR] Unable to register as a container instance with ECS: NoCredentialProviders: no valid providers in chain. Deprecated.
For verbose messaging see aws.Config.CredentialsChainVerboseErrors
2019-07-15T19:57:44Z [ERROR] Error registering: NoCredentialProviders: no valid providers in chain. Deprecated.
For verbose messaging see aws.Config.CredentialsChainVerboseErrors