'How do I configure "ulimits" for a Docker container running in AWS ECS?
My Java application appears to be running out of "open files" limit when running in a Docker container in AWS ECS. Upon further investigation, I found that the open files limit defaults to 1024.
Typically, in Linux I would edit /etc/security/limits.conf
. That does not appear to take effect when I modify that file in my Docker container.
I know I can also pass command line ulimit parameters to docker run
as documented here. But I do not have direct access to the Docker command line in ECS. There's gotta be a way to do it via a Task definition. How do I accomplish this ?
Solution 1:[1]
ECS task definition JSON allows you to set ulimits. The Ulimits on ecs task definition correspond to Ulimits in docker run.
Please refer to the following page for more information: http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html
Solution 2:[2]
Via the Console navigate to the task definitions and under the "Resource Limits" section you can set the NOFILE soft/hard limits
For cloudformation you can set it via the task definition > Container Definition > Ulimits https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecs-taskdefinition-containerdefinitions.html#cfn-ecs-taskdefinition-containerdefinition-ulimits
Be mindful of the fact that you should keep the hard limit below 1/10th of the afforded memory in Kilobytes to this task.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Shibashis |
Solution 2 | Austin Poole |