简体   繁体   English

如何为在 AWS ECS 中运行的 Docker 容器配置“ulimits”?

[英]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.

相关问题 如何从在自动缩放组后面运行并连接到 jms 队列的 aws ecs docker 容器中排出消息 - How to drain message from aws ecs docker container which is running behind autoscaling group and connected to jms queue 如何使用 Fargate 在 AWS ECS 中正在运行的容器中运行命令 - How can I run commands in a running container in AWS ECS using Fargate 在 AWS ECS 容器中运行节点应用程序的问题 - Issue with running Node application in AWS ECS container 我们可以在 AWS ECS docker 容器上挂载 EFS 吗? - Can we mount EFS on AWS ECS docker container? 亚马逊 AWS ECS 容器 Docker 端口绑定不正确 - Amazon AWS ECS Container Docker Port not binding correctly 如何将更新的 Docker 图像部署到 Amazon ECS 任务? - How do I deploy updated Docker images to Amazon ECS tasks? 如何使用 Fluentbit 将 AWS ECS 连接到 ElasticSearch? - How do I connect AWS ECS to ElasticSearch with Fluentbit? 如何使用 intelliJ 中的 AWS 工具包将文件复制到运行 Lambda 的 docker 容器 - How to copy file to docker container running Lambda with AWS Toolkit in intelliJ 如何为 Terraform 配置 AWS MFA? - How do I configure AWS MFA for Terraform? Angular 2 应用程序部署在 AWS 上运行的 docker 容器中 - Angular 2 app deploy in a docker Container running on AWS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM