Maximum Number of Handles

Function Description

System containers support limit on the number of file handles. File handles include common file handles and network sockets. When starting a container, you can specify the –files-limit parameter to limit the maximum number of handles opened in the container.

Parameter Description

Command

Parameter

Value Description

isula create/run

--files-limit

  

  • The value cannot be negative and must be an integer.
  • The value 0 indicates that the number is not limited by the parameter. The maximum number is determined by the current kernel files cgroup.

Constraints

  • If the value of –files-limit is too small, the system container may fail to run the exec command and the error “open temporary files” is reported. Therefore, you are advised to set the parameter to a large value.
  • File handles include common file handles and network sockets.

Example

To use –files-limit to limit the number of file handles opened in a container, run the following command to check whether the kernel supports files cgroup:

[root@localhost ~]# cat /proc/1/cgroup | grep files
10:files:/

If files is displayed, files cgroup is supported.

Start the container, specify the –files-limit parameter, and check whether the files.limit parameter is successfully written.

[root@localhost ~]# isula run  -tid --files-limit 1024 --system-container  --external-rootfs /tmp/root-fs  empty init 01e82fcf97d4937aa1d96eb8067f9f23e4707b92de152328c3fc0ecb5f64e91d 
[root@localhost ~]# isula exec -it 01e82fcf97d4 bash 
[root@localhost ~]# cat /sys/fs/cgroup/files/files.limit 
1024 

The preceding information indicates that the number of file handles is successfully limited in the container.

Rating

search results about are found