1

I basically follow the document in AWS https://docs.aws.amazon.com/AmazonECS/latest/developerguide/example_user_data_scripts.html

I created a Centos 7 and tried to install docker, ese-agent within my EC2 instance.

Here is my service file

/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

I also did the enable and start command

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

However, when I inspect the status by typing systemctl, it threw the failed status.

UNIT                                                          LOAD   ACTIVE SUB       DESCRIPTION

docker_container_ecs_agent.service                            loaded failed failed    docker_container_ecs_agent.service

Update-Error logs

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 logs

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.