NAME 名称

podman-update - Update the configuration of a given container
podman-update - 更新给定容器的配置

SYNOPSIS 概要

podman update [options] container
podman update [选项] 容器

podman container update [options] container
podman 容器 update [选项] 容器

DESCRIPTION 描述

Updates the configuration of an already existing container, allowing different resource limits to be set. The currently supported options are a subset of the podman create/run resource limit options.
更新已存在容器的配置,允许设置不同的资源限制。当前支持的选项是 podman create/run 资源限制选项的一个子集。

OPTIONS 选项

--blkio-weight=weight --blkio-weight=权重 ¶

Block IO relative weight. The weight is a value between 10 and 1000.
块 IO 相对权重。权重的取值范围为 10 到 1000。

This option is not supported on cgroups V1 rootless systems.
此选项不支持 cgroups V1 无根系统。

--blkio-weight-device=device:weight
--blkio-weight-device=设备:权重 ¶

Block IO relative device weight.
块 IO 相对设备权重。

--cpu-period=limit

Set the CPU period for the Completely Fair Scheduler (CFS), which is a duration in microseconds. Once the container’s CPU quota is used up, it will not be scheduled to run until the current period ends. Defaults to 100000 microseconds.
设置完全公平调度器(CFS)的 CPU 周期,单位为微秒。一旦容器的 CPU 配额用完,它将不会被调度运行,直到当前周期结束。默认为 100000 微秒。

On some systems, changing the resource limits may not be allowed for non-root users. For more details, see https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error
在某些系统上,非 root 用户可能无法更改资源限制。有关更多详细信息,请参阅 https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error

This option is not supported on cgroups V1 rootless systems.
此选项不支持 cgroups V1 无根系统。

--cpu-quota=limit

Limit the CPU Completely Fair Scheduler (CFS) quota.
限制 CPU 完全公平调度器(CFS)的配额。

Limit the container’s CPU usage. By default, containers run with the full CPU resource. The limit is a number in microseconds. If a number is provided, the container is allowed to use that much CPU time until the CPU period ends (controllable via --cpu-period).
限制容器的 CPU 使用率。默认情况下,容器以完整的 CPU 资源运行。限制是以微秒为单位的数字。如果提供了一个数字,容器可以使用那么多的 CPU 时间,直到 CPU 周期结束(可通过 --cpu-period 控制)。

On some systems, changing the resource limits may not be allowed for non-root users. For more details, see https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error
在某些系统上,非 root 用户可能无法更改资源限制。有关更多详细信息,请参阅 https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error

This option is not supported on cgroups V1 rootless systems.
此选项不支持 cgroups V1 无根系统。

--cpu-rt-period=microseconds
--cpu-rt-period=微秒 ¶

Limit the CPU real-time period in microseconds.
限制 CPU 实时周期为微秒。

Limit the container’s Real Time CPU usage. This option tells the kernel to restrict the container’s Real Time CPU usage to the period specified.
限制容器的实时 CPU 使用率。此选项告诉内核将容器的实时 CPU 使用率限制在指定的周期内。

This option is only supported on cgroups V1 rootful systems.
该选项仅在 cgroups V1 根系统上受支持。

--cpu-rt-runtime=microseconds
--cpu-rt-runtime=微秒 ¶

Limit the CPU real-time runtime in microseconds.
以微秒为单位限制 CPU 的实时运行时间。

Limit the containers Real Time CPU usage. This option tells the kernel to limit the amount of time in a given CPU period Real Time tasks may consume. Ex: Period of 1,000,000us and Runtime of 950,000us means that this container can consume 95% of available CPU and leave the remaining 5% to normal priority tasks.
限制容器的实时 CPU 使用率。此选项告诉内核限制在给定 CPU 周期内实时任务可以消耗的时间量。例如:周期为 1,000,000 微秒,运行时间为 950,000 微秒意味着此容器可以消耗可用 CPU 的 95%,并将剩余的 5% 留给正常优先级任务。

The sum of all runtimes across containers cannot exceed the amount allotted to the parent cgroup.
所有容器中的运行时间总和不能超过分配给父 cgroup 的数量。

This option is only supported on cgroups V1 rootful systems.
该选项仅在 cgroups V1 根系统上受支持。

--cpu-shares, -c=shares
--cpu-shares, -c=份额 ¶

CPU shares (relative weight).
CPU 份额(相对权重)。

By default, all containers get the same proportion of CPU cycles. This proportion can be modified by changing the container’s CPU share weighting relative to the combined weight of all the running containers. Default weight is 1024.
默认情况下,所有容器获得相同比例的 CPU 周期。可以通过修改容器的 CPU 份额权重相对于所有运行容器的组合权重来修改此比例。默认权重为 1024。

The proportion only applies when CPU-intensive processes are running. When tasks in one container are idle, other containers can use the left-over CPU time. The actual amount of CPU time varies depending on the number of containers running on the system.
仅当运行 CPU 密集型进程时,比例才适用。当一个容器中的任务处于空闲状态时,其他容器可以使用剩余的 CPU 时间。实际的 CPU 时间量取决于系统上运行的容器数量。

For example, consider three containers, one has a cpu-share of 1024 and two others have a cpu-share setting of 512. When processes in all three containers attempt to use 100% of CPU, the first container receives 50% of the total CPU time. If a fourth container is added with a cpu-share of 1024, the first container only gets 33% of the CPU. The remaining containers receive 16.5%, 16.5% and 33% of the CPU.
例如,考虑三个容器,一个的 cpu-share 为 1024,另外两个的 cpu-share 设置为 512。当所有三个容器中的进程尝试使用 CPU 的 100% 时,第一个容器将获得总 CPU 时间的 50%。如果添加一个 cpu-share 为 1024 的第四个容器,则第一个容器只能获得 CPU 的 33%。其余容器分别获得 CPU 的 16.5%,16.5% 和 33%。

On a multi-core system, the shares of CPU time are distributed over all CPU cores. Even if a container is limited to less than 100% of CPU time, it can use 100% of each individual CPU core.
在多核系统上,CPU 时间的份额分布在所有 CPU 核心上。即使容器被限制在少于 100% 的 CPU 时间,它仍然可以使用每个单独的 CPU 核心的 100%。

For example, consider a system with more than three cores. If the container C0 is started with --cpu-shares=512 running one process, and another container C1 with --cpu-shares=1024 running two processes, this can result in the following division of CPU shares:
例如,考虑一个具有三个以上核心的系统。如果容器 C0 使用 --cpu-shares=512 启动并运行一个进程,另一个容器 C1 使用 --cpu-shares=1024 启动并运行两个进程,这可能导致 CPU 分配如下:

PID

container

CPU

CPU share CPU 分配

100

C0

0

100% of CPU0 CPU0 的 100%

101

C1

1

100% of CPU1 CPU1 的 100%

102

C1

2

100% of CPU2 CPU2 的 100%

On some systems, changing the resource limits may not be allowed for non-root users. For more details, see https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error
在某些系统上,非 root 用户可能无法更改资源限制。有关更多详细信息,请参阅 https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error

This option is not supported on cgroups V1 rootless systems.
此选项不支持 cgroups V1 无根系统。

--cpus=number

Number of CPUs. The default is 0.0 which means no limit. This is shorthand for --cpu-period and --cpu-quota, therefore the option cannot be specified with --cpu-period or --cpu-quota.
CPU 的数量。默认值为 0.0,表示没有限制。这是 --cpu-period 和 --cpu-quota 的简写,因此不能与 --cpu-period 或 --cpu-quota 一起指定该选项。

On some systems, changing the CPU limits may not be allowed for non-root users. For more details, see https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error
在某些系统上,更改 CPU 限制可能不允许非 root 用户。有关更多详细信息,请参阅 https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error

This option is not supported on cgroups V1 rootless systems.
此选项不支持 cgroups V1 无根系统。

--cpuset-cpus=number

CPUs in which to allow execution. Can be specified as a comma-separated list (e.g. 0,1), as a range (e.g. 0-3), or any combination thereof (e.g. 0-3,7,11-15).
允许执行的 CPU。可以指定为逗号分隔的列表(例如 0,1),作为范围(例如 0-3),或两者的任意组合(例如 0-3,7,11-15)。

On some systems, changing the resource limits may not be allowed for non-root users. For more details, see https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error
在某些系统上,非 root 用户可能无法更改资源限制。有关更多详细信息,请参阅 https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error

This option is not supported on cgroups V1 rootless systems.
此选项不支持 cgroups V1 无根系统。

--cpuset-mems=nodes

Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems.
允许执行的内存节点(MEMs)(0-3, 0,1)。仅在 NUMA 系统上有效。

If there are four memory nodes on the system (0-3), use --cpuset-mems=0,1 then processes in the container only uses memory from the first two memory nodes.
如果系统上有四个内存节点(0-3),则使用--cpuset-mems=0,1,然后容器中的进程仅使用来自前两个内存节点的内存。

On some systems, changing the resource limits may not be allowed for non-root users. For more details, see https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error
在某些系统上,非 root 用户可能无法更改资源限制。有关更多详细信息,请参阅 https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error

This option is not supported on cgroups V1 rootless systems.
此选项不支持 cgroups V1 无根系统。

--device-read-bps=path:rate

Limit read rate (in bytes per second) from a device (e.g. --device-read-bps=/dev/sda:1mb).
限制从设备读取速率(以每秒字节数为单位)(例如 --device-read-bps=/dev/sda:1mb)。

On some systems, changing the resource limits may not be allowed for non-root users. For more details, see https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error
在某些系统上,非 root 用户可能无法更改资源限制。有关更多详细信息,请参阅 https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error

This option is not supported on cgroups V1 rootless systems.
此选项不支持 cgroups V1 无根系统。

--device-read-iops=path:rate

Limit read rate (in IO operations per second) from a device (e.g. --device-read-iops=/dev/sda:1000).
限制从设备读取速率(每秒 IO 操作次数)(例如 --device-read-iops=/dev/sda:1000)。

On some systems, changing the resource limits may not be allowed for non-root users. For more details, see https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error
在某些系统上,非 root 用户可能无法更改资源限制。有关更多详细信息,请参阅 https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error

This option is not supported on cgroups V1 rootless systems.
此选项不支持 cgroups V1 无根系统。

--device-write-bps=path:rate

Limit write rate (in bytes per second) to a device (e.g. --device-write-bps=/dev/sda:1mb).
限制设备的写入速率(以每秒字节为单位)(例如 --device-write-bps=/dev/sda:1mb)。

On some systems, changing the resource limits may not be allowed for non-root users. For more details, see https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error
在某些系统上,非 root 用户可能无法更改资源限制。有关更多详细信息,请参阅 https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error

This option is not supported on cgroups V1 rootless systems.
此选项不支持 cgroups V1 无根系统。

--device-write-iops=path:rate

Limit write rate (in IO operations per second) to a device (e.g. --device-write-iops=/dev/sda:1000).
限制设备的写入速率(以每秒的 IO 操作次数计)(例如 --device-write-iops=/dev/sda:1000)。

On some systems, changing the resource limits may not be allowed for non-root users. For more details, see https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error
在某些系统上,非 root 用户可能无法更改资源限制。有关更多详细信息,请参阅 https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error

This option is not supported on cgroups V1 rootless systems.
此选项不支持 cgroups V1 无根系统。

--memory, -m=number[unit]
--memory, -m=数字[单位] ¶

Memory limit. A unit can be b (bytes), k (kibibytes), m (mebibytes), or g (gibibytes).
内存限制。单位可以是 b(字节)、k(基比字节)、m(兆比字节)或 g(吉比字节)。

Allows the memory available to a container to be constrained. If the host supports swap memory, then the -m memory setting can be larger than physical RAM. If a limit of 0 is specified (not using -m), the container’s memory is not limited. The actual limit may be rounded up to a multiple of the operating system’s page size (the value is very large, that’s millions of trillions).
允许限制容器可用的内存。如果主机支持交换内存,那么 -m 内存设置可以大于物理 RAM。如果指定了 0 的限制(不使用 -m),则容器的内存不受限制。实际限制可能会舍入到操作系统页面大小的倍数(该值非常大,是百万亿的数量级)。

This option is not supported on cgroups V1 rootless systems.
此选项不支持 cgroups V1 无根系统。

--memory-reservation=number[unit]

Memory soft limit. A unit can be b (bytes), k (kibibytes), m (mebibytes), or g (gibibytes).
内存软限制。单位可以是 b(字节)、k(kibibytes)、m(mebibytes)或 g(gibibytes)。

After setting memory reservation, when the system detects memory contention or low memory, containers are forced to restrict their consumption to their reservation. So always set the value below --memory, otherwise the hard limit takes precedence. By default, memory reservation is the same as memory limit.
设置内存保留后,当系统检测到内存争用或低内存时,容器被强制限制其消耗到其保留值。因此,始终将值设置为低于--memory,否则硬限制优先。默认情况下,内存保留与内存限制相同。

This option is not supported on cgroups V1 rootless systems.
此选项不支持 cgroups V1 无根系统。

--memory-swap=number[unit]

A limit value equal to memory plus swap. A unit can be b (bytes), k (kibibytes), m (mebibytes), or g (gibibytes).
一个等于内存加交换空间的限制值。单位可以是 b(字节)、k(kibibytes)、m(mebibytes)或 g(gibibytes)。

Must be used with the -m (--memory) flag. The argument value must be larger than that of -m (--memory) By default, it is set to double the value of --memory.
必须与 -m (--memory) 标志一起使用。参数值必须大于 -m (--memory) 的值。默认情况下,它设置为 --memory 值的两倍。

Set number to -1 to enable unlimited swap.
将数字设置为 -1 以启用无限交换。

This option is not supported on cgroups V1 rootless systems.
此选项不支持 cgroups V1 无根系统。

--memory-swappiness=number
--memory-swappiness=数字 ¶

Tune a container’s memory swappiness behavior. Accepts an integer between 0 and 100.
调整容器的内存交换行为。接受介于 0 和 100 之间的整数。

This flag is only supported on cgroups V1 rootful systems.
此标志仅在 cgroups V1 根系统上受支持。

--pids-limit=limit

Tune the container’s pids limit. Set to -1 to have unlimited pids for the container. The default is 2048 on systems that support “pids” cgroup controller.
调整容器的 pids 限制。设置为 -1 可使容器的 pids 无限制。在支持“pids” cgroup 控制器的系统上,默认值为 2048。

--restart=policy

Restart policy to follow when containers exit. Restart policy does not take effect if a container is stopped via the podman kill or podman stop commands.
容器退出时要遵循的重启策略。 如果通过 podman kill 或 podman stop 命令停止容器,则重启策略不会生效。

Valid policy values are: 有效的策略值为:

  • no : Do not restart containers on exit
    no :退出时不重新启动容器

  • never : Synonym for no; do not restart containers on exit
    never :no 的同义词; 退出时不重新启动容器

  • on-failure[:max_retries] : Restart containers when they exit with a non-zero exit code, retrying indefinitely or until the optional max_retries count is hit
    on-failure[:max_retries] :当容器以非零退出代码退出时重新启动容器,无限重试,或直到达到可选的 max_retries 计数

  • always : Restart containers when they exit, regardless of status, retrying indefinitely
    always :当容器退出时重新启动容器,无论状态如何,无限重试

  • unless-stopped : Identical to always
    unless-stopped :与 always 相同

Podman provides a systemd unit file, podman-restart.service, which restarts containers after a system reboot.
Podman 提供了一个 systemd 单元文件,podman-restart.service,在系统重启后重新启动容器。

When running containers in systemd services, use the restart functionality provided by systemd. In other words, do not use this option in a container unit, instead set the Restart= systemd directive in the [Service] section. See podman-systemd.unit(5) and systemd.service(5).
在 systemd 服务中运行容器时,请使用 systemd 提供的重启功能。换句话说,请不要在容器单元中使用此选项,而是在 [Service] 部分中设置 Restart= systemd 指令。请参阅 podman-systemd.unit(5) 和 systemd.service(5)。

EXAMPLEs 示例

Update a container with a new cpu quota and period.
更新容器的 CPU 配额和周期。

podman update --cpus=5 myCtr

Update a container with all available options for cgroups v2.
使用所有可用的选项更新 cgroups v2 中的容器。

podman update --cpus 5 --cpuset-cpus 0 --cpu-shares 123 --cpuset-mems 0 --memory 1G --memory-swap 2G --memory-reservation 2G --blkio-weight-device /dev/zero:123 --blkio-weight 123 --device-read-bps /dev/zero:10mb --device-write-bps /dev/zero:10mb --device-read-iops /dev/zero:1000 --device-write-iops /dev/zero:1000 --pids-limit 123 ctrID

Update a container with all available options for cgroups v1.
使用所有可用的选项更新 cgroups v1 中的容器。

podman update --cpus 5 --cpuset-cpus 0 --cpu-shares 123 --cpuset-mems 0 --memory 1G --memory-swap 2G --memory-reservation 2G --memory-swappiness 50 --pids-limit 123 ctrID

SEE ALSO 参见 ¶

podman(1), podman-create(1), podman-run(1)

HISTORY 历史 ¶

August 2022, Originally written by Charlie Doern cdoern@redhat.com
2022 年 8 月,原文作者为 Charlie Doern cdoern@redhat.com