配置容器内的ulimit值

描述

可以通过参数控制执行程序的资源。

用法

在容器create/run时配置—ulimit参数,或通过daemon端配置,控制容器中执行程序的资源。

参数

通过两种方法配置ulimit

  1. isula create/run时使用—ulimit =[:]来控制shell执行程序的资源。

    参数项

    参数说明

    取值范围

    是否必选

    —ulimit

    限制shell执行程序的资源

    soft/hard是64位整数(int64)。soft取值 <= hard取值,如果仅仅指定了soft的取值,则hard=soft。对于某些类型的资源并不支持负数,详见下表

  2. 通过daemon端参数或配置文件

    详见”(命令行参数说明”与”部署方式”的—default-ulimits相关选项。

    —ulimit可以对以下类型的资源进行限制。

    类型

    说明

    取值范围

    core

    limits the core file size (KB)

    64位整数(INT64),无单位。可以为0、负、其中-1表示UNLIMITED,即不做限制,其余的负数会被强制转换为一个大的正整数。

    cpu

    max CPU time (MIN)

    data

    max data size (KB)

    fsize

    maximum filesize (KB)

    locks

    max number of file locks the user can hold

    memlock

    max locked-in-memory address space (KB)

    msgqueue

    max memory used by POSIX message queues (bytes)

    nice

    nice priority

    nproc

    max number of processes

    rss

    max resident set size (KB)

    rtprio

    max realtime priority

    rttime

    realtime timeout

    sigpending

    max number of pending signals

    stack

    max stack size (KB)

    nofile

    max number of open file descriptors

    64位整数(int64),无单位。不可以为负,负数被强转为大数,设置时会出现Operation not permitted

示例

在容器的创建或者运行时,加上—ulimit =[:]即可,如:

  1. isula create/run -tid --ulimit nofile=1024:2048 busybox sh

约束

不能在daemon.json和/etc/sysconfig/iSulad文件(或isulad命令行)中同时配置ulimit限制,否则isulad启动会报错。