How can I automate the cleanup of Docker containers and images in Amazon ECS?

1 minute read
0

I want to automatically clean up Docker containers and images in Amazon ECS.

Resolution

The Amazon ECS container agent (for versions 1.13.0 or later) automatically cleans up stopped tasks and Docker images that aren't used by tasks on your container instances. By default, stopped tasks and Docker images are cleaned up and the containers are removed every three hours.

To change the wait period before a container is removed, use the ECS_ENGINE_TASK_CLEANUP_WAIT_DURATION variable.  

Important: If you set ECS_DISABLE_IMAGE_CLEANUP to true, then automated image cleanup is turned off on your container instance and your images aren't automatically removed.

For more information on the clean-up workflow, see Automatic Amazon ECS task and image clean up.

Related information

Amazon Elastic Container Service Agent on GitHub

Available parameters

Updating the Amazon ECS container agent

Creating a container image for use on Amazon ECS

AWS OFFICIAL
AWS OFFICIALUpdated 11 days ago