P E N C I L
Login
Troubleshoot ECS agent
  1. Issue:  You cannot start / stop your ECS task. 

  2. Requirements

    1. This article assume that you know how to connect to EC2 instance with ssh

    2. Your EC2 instance was created with one of ECS optimized AMI images. Those image are bundle with ECS daemon and ECS docker
      http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-optimized_AMI.html

  3. Basics

    1. What is ECS agent?

      1. ECS agent is a daemon which manages the ECS tasks. It pulls the docker of task, start it, stop it.

      2. ECS agent comprise of 

        1. An ECS daemon 

        2. An ECS docker container

  4. Where is the log of ECS agent?

    1. The logs of  ECS daemon
      /var/log/ecs/ecs-init.log

    2. The logs of ECS docker container
      /var/log/ecs/ecs-agent.log.***
      Here you can see the log of pulling docker image for the ECS task, start/stop the container of those images

  5. How to restart ECS agent?

    1. sudo stop ecs
      sudo start ecs

    2. The ecs docker container is stopped / start automatically 
      you can check with docker ps 
      CONTAINERID  IMAGE                                             COMMAND
      6db819ca3e1a amazon/amazon-ecs-agent:latest "/agent"

  6. Delete checkpoint file.
    If the logs says something about the checkpoint was fail, delete file
    /var/lib/ecs/data/ecs_agent_data.json

  7. Where is ECS agent config?
    /etc/ecs/ecs.config