ECS: docker ps doesn't print the running task

Viewed 278

I have a cluster as well as a task on ECS.

I can see that the task is running:

enter image description here

And the service is active:

enter image description here

And the associated EC2 instance is active:

enter image description here

But docker ps on this instance prints only one container - the ECS agent. Where is my task??

$ docker ps
CONTAINER ID        IMAGE                            COMMAND             CREATED             STATUS                 PORTS               NAMES
8d0416bfd684        amazon/amazon-ecs-agent:latest   "/agent"            3 hours ago         Up 3 hours (healthy)                       ecs-agent
1 Answers

By extending to @jordanm comment, I prefer to watch docker ps where container keeps restarting as ECS agent automatically remove stop container if the interval is still low then docker ps -a might not show because of removing old container by ECS.

watch docker ps

ECS_ENGINE_TASK_CLEANUP_WAIT_DURATION

This variable specifies the time to wait before removing any containers that belong to stopped tasks. The image cleanup process cannot delete an image as long as there is a container that references it. After images are not referenced by any containers (either stopped or running), then the image becomes a candidate for cleanup. By default, this parameter is set to 3 hours but you can reduce this period to as low as 1 minute, if you need to for your application.

automated_container_cleanup

Or to debug such issue with service type container, I recommend

  • Increase the unhealthy threshold
  • Change CMD with working CMD and then debug the container if the type is Ec2
Related