[英]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.我的 Java 应用程序在 AWS ECS 中的 Docker 容器中运行时似乎超出了“打开文件”限制。 Upon further investigation, I found that the open files limit defaults to 1024.经过进一步调查,我发现打开文件限制默认为 1024。
Typically, in Linux I would edit /etc/security/limits.conf
.通常,在 Linux 中,我会编辑/etc/security/limits.conf
。 That does not appear to take effect when I modify that file in my Docker container.当我在我的 Docker 容器中修改该文件时,这似乎没有生效。
I know I can also pass command line ulimit parameters to docker run
as documented here .我知道我也可以将命令行 ulimit 参数传递给docker run
,如此处所述。 But I do not have direct access to the Docker command line in ECS.但是我没有直接访问ECS中的Docker命令行。 There's gotta be a way to do it via a Task definition.必须有一种方法可以通过任务定义来完成。 How do I accomplish this?我该如何做到这一点?
ECS task definition JSON allows you to set ulimits. ECS任务定义JSON允许您设置ulimits。 The Ulimits on ecs task definition correspond to Ulimits in docker run. ecs任务定义上的Ulimits对应于docker run中的Ulimits。
Please refer to the following page for more information: http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html 请参阅以下页面以了解更多信息: http : //docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html
Via the Console navigate to the task definitions and under the "Resource Limits" section you can set the NOFILE soft/hard limits通过控制台导航到任务定义,在“资源限制”部分下,您可以设置 NOFILE 软/硬限制
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对于 cloudformation,您可以通过任务定义 > 容器定义 > 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.请注意,您应将此任务的硬限制保持在所提供的 memory(以千字节为单位)的 1/10 以下。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.