how to set ulimit / file descriptor on docker container the image tag is phusion/baseimage-docker

前端 未结 8 2023
失恋的感觉
失恋的感觉 2020-11-28 06:32

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 trie

相关标签:
8条回答
  • 2020-11-28 07:18

    For boot2docker, we can set it on /var/lib/boot2docker/profile, for instance:

    ulimit -n 2018

    Be warned not to set this limit too high as it will slow down apt-get! See bug #1332440. I had it with debian jessie.

    0 讨论(0)
  • 2020-11-28 07:20

    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.

    1. Remove sys_resource from lxc_template.go and recompile docker. Then you'll be able to set the ulimit as high as you like.

    or

    1. Stop the docker demon. Change the ulimit settings on the host. Start the docker demon. It now has your revised limits, and its child processes as well.

    I applied the second method:

    1. sudo service docker stop;

    2. changed the limits in /etc/security/limits.conf

    3. reboot the machine

    4. run my container

    5. 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

    0 讨论(0)
提交回复
热议问题