I am using docker environment in an Elastic beanstalk cluster but having trouble with open files limit. I verified that on the host my open files limit is 65535, but in the docker container the soft limit is 1024 and hard limit is 4096. I'd like to increase these limits inside the container, but when I tried to do that manually I got error even with root:
root@4020d4faf5fc:/# ulimit -n 20000
bash: ulimit: open files: cannot modify limit: Operation not permitted
A similar thread also shares some ideas but seems like those are related to increasing limit of the host vs container.
You would need the SYS_RESOURCE
Linux capability to set ulimit from within the container, which would typically be specified using the --cap-add
flag with docker run
.
With Elastic Beanstalk this can be accomplished in the following ways:
services.<your service>
key)
ulimits:
nofile:
soft: 20000
hard: 20000
Dockerrun.aws.json
version 1 for single-container Docker environments, see Task Definition Resource Limits:
{
"AWSEBDockerrunVersion": "1",
.
.
.
"ulimits": [
{
"name": "nofile",
"softLimit": 20000,
"hardLimit": 20000
}
]
}
Dockerrun.aws.json
version 2 for multi-container Docker environments, this gist may be useful
{
"AWSEBDockerrunVersion": "2",
"containerDefinitions": [
{
.
.
.
"ulimits": [
{
"hardLimit": 20000,
"name": "nofile",
"softLimit": 20000
}
]
}
]
}
See also the Elastic Beanstalk Docker docs.