Increase ulimit in ubuntu and docker

Posted ExplorerMan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Increase ulimit in ubuntu and docker相关的知识,希望对你有一定的参考价值。

What is ulimit?

It is a number of open file descriptors per process. They can all refer to the same file, or different files. It prevent single users from using too many system resources.

How can is check ulimit in current shell?

Run ulimit -a command from terminal.

Output of the above command:

技术图片
技术图片

How to set ulimit in current shell?

ulimit -n {$no of files}

For example -> If you want to set no of open files 65535 below is the command you need to run on terminal. ulimit -n 65535 ;

How to set ulimit permanent?

For the ulimits to persists across reboots we need to set the ulimit values in the configuration file

/etc/security/limits.conf.

Format ->

#[domain]   [type]  [item]  [value]

domain → a user name or group name

type -> can have the two values (soft| hard)

item -> the property to set

value -> value of the property.

For example -> to add limit of number of files for user root:

技术图片
技术图片

to set limit of number of files valid for all users:

技术图片
技术图片

How to set ulimit in Docker?

Due to some security reason. docker currently not extends host ulimit property.

There are couple of ways to set following are the ways:

  • The latest docker supports setting ulimits through the command line and the API. For instance, docker run takes — ulimit <type>=<soft>:<hard> .
  • set ulimit -n 65535 in the file /etc/init.d/docker

以上是关于Increase ulimit in ubuntu and docker的主要内容,如果未能解决你的问题,请参考以下文章

【OpenSSH】关于升级openssh后ulimit不生效问题的解决方法

Difference between ulimit, lsof, cat /proc/sys/fs/file-max

如何在 Ubuntu 中增加 Neo4j 的最大文件打开限制(ulimit)?

Ubuntu elasticsearch max virtual memory areas vm.max_map_count [65530] is too low, increase to at le

Ubuntu解决sudo: source: command not found错误

sklearn 逻辑回归Increase the number of iterations (max_iter) or scale the data as shown in解决方案