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.