Changing ECS Agent Timeout

Cory O'Daniel
CoryODaniel
Published in
1 min readMar 7, 2017

I had a docker container running on Amazon’s ECS that was handling work from Simple Workflow. When a new image was deployed long running jobs were being terminated partially through their work when what I wanted to happen was let the job finish it’s work, then gracefully shutdown.

I figured I could trap SIGTERM then cease to take more work off of the task list, but it turns out the ECS AGent kills a container after 30s of sending SIGTERM.

But, aha, there is an ECS Agent environment variable ECS_CONTAINER_STOP_TIMEOUT that can be set to lengthen the time before the container is killed.

This configuration option is set on the EC2 instance. SSH in and:

Valid values are pretty much any sane integer plus “ns”, “us” (or “µs”), “ms”, “s”, “m”, and “h”.

Woot, totally killin’ it.

--

--

Cory O'Daniel
CoryODaniel

SQL, kubernetes, elixir, ruby, node, tacos, whiskey, repeat.