I need to set the file descriptor limit correctly on the docker container I connect to container with ssh (https://github.com/phusion/baseimage-docker)
Already tried:
The output it always the same.
bash: ulimit: open files: cannot modify limit: Operation not permitted
It is frequently used by database management applications such as Oracle or Sybase to lock shared memory for a shared pool so that it is always in memory for access by multiple sessions.
nofile: -n: file descriptors. This ulimit settings parameters tells how many file descriptor a mongodb process can use. MongoDB internally uses file for storing connections, journal files, indexes and datafiles. MongoDB recommeneds to set nofile to 64000.
The latest docker supports setting ulimits through the command line and the API. For instance, docker run
takes --ulimit <type>=<soft>:<hard>
and there can be as many of these as you like. So, for your nofile, an example would be --ulimit nofile=262144:262144
If using the docker-compose file, Based on docker compose version 2.x We can set like as below, by overriding the default config.
ulimits:
nproc: 65535
nofile:
soft: 26677
hard: 46677
https://docs.docker.com/compose/compose-file/compose-file-v3/
After some searching I found this on a Google groups discussion:
docker currently inhibits this capability for enhanced safety.
That is because the ulimit settings of the host system apply to the docker container. It is regarded as a security risk that programs running in a container can change the ulimit settings for the host.
The good news is that you have two different solutions to choose from.
sys_resource
from lxc_template.go
and recompile docker. Then
you'll be able to set the ulimit as high as you like.or
I applied the second method:
sudo service docker stop;
changed the limits in /etc/security/limits.conf
reboot the machine
run my container
run ulimit -a
in the container to confirm the open files limit has been inherited.
See: https://groups.google.com/forum/#!searchin/docker-user/limits/docker-user/T45Kc9vD804/v8J_N4gLbacJ
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With