NAME 名称

podman-create - Create a new container
podman-create - 创建一个新容器

SYNOPSIS 概要

podman create [options] image [command [arg …]]
podman create [选项] 镜像 [命令 [参数 …]]

podman container create [options] image [command [arg …]]
podman container create [选项] 镜像 [命令 [参数 …]]

DESCRIPTION 描述

Creates a writable container layer over the specified image and prepares it for running the specified command. The container ID is then printed to STDOUT. This is similar to podman run -d except the container is never started. Use the podman start container command to start the container at any point.
在指定的镜像上创建一个可写的容器层,并准备运行指定的命令。然后将容器 ID 打印到 STDOUT。这类似于 podman run -d,但容器从未启动。使用 podman start container 命令随时启动容器。

The initial status of the container created with podman create is ‘created’.
使用 podman create 创建的容器的初始状态为“created”。

Default settings for flags are defined in containers.conf. Most settings for remote connections use the server’s containers.conf, except when documented in man pages.
标志的默认设置在 containers.conf 中定义。大多数远程连接的设置使用服务器的 containers.conf,除非在手册页中有记录。

IMAGE 图像 ¶

The image is specified using transport:path format. If no transport is specified, the docker (container registry) transport is used by default. For remote Podman, including Mac and Windows (excluding WSL2) machines, docker is the only allowed transport.
使用 transport:path 格式指定图像。如果未指定传输方式,默认情况下使用 docker (容器注册表)传输。对于远程 Podman,包括 Mac 和 Windows(不包括 WSL2)机器, docker 是唯一允许的传输方式。

dir:path An existing local directory path storing the manifest, layer tarballs and signatures as individual files. This is a non-standardized format, primarily useful for debugging or noninvasive container inspection.
dir:path 存储清单、层 tarballs 和签名作为单独文件的现有本地目录路径。这是一种非标准化格式,主要用于调试或非侵入式容器检查。

$ podman save --format docker-dir fedora -o /tmp/fedora
$ podman create dir:/tmp/fedora echo hello

docker://docker-reference (Default) An image reference stored in a remote container image registry. Example: “quay.io/podman/stable:latest”. The reference can include a path to a specific registry; if it does not, the registries listed in registries.conf is queried to find a matching image. By default, credentials from podman login (stored at $XDG_RUNTIME_DIR/containers/auth.json by default) is used to authenticate; otherwise it falls back to using credentials in $HOME/.docker/config.json.
docker://docker-reference(默认)存储在远程容器镜像注册表中的图像引用。示例:“quay.io/podman/stable:latest”。引用可以包括到特定注册表的路径;如果没有,则将查询 registries.conf 中列出的注册表以找到匹配的图像。默认情况下,将使用来自 podman login 的凭据(默认情况下存储在 $XDG_RUNTIME_DIR/containers/auth.json 中)进行身份验证;否则将退回到使用 $HOME/.docker/config.json 中的凭据。

$ podman create registry.fedoraproject.org/fedora:latest echo hello

docker-archive:path[:docker-reference] An image stored in the docker save formatted file. docker-reference is only used when creating such a file, and it must not contain a digest.
docker-archive:path[:docker-reference] 存储在 docker save 格式文件中的图像。创建此类文件时仅使用 docker-reference,并且不得包含摘要。

$ podman save --format docker-archive fedora -o /tmp/fedora
$ podman create docker-archive:/tmp/fedora echo hello

docker-daemon:docker-reference An image in docker-reference format stored in the docker daemon internal storage. The docker-reference can also be an image ID (docker-daemon:algo:digest).
docker-daemon:docker-reference 以 docker-reference 格式存储在 docker 守护程序内部存储中的图像。docker-reference 也可以是图像 ID(docker-daemon:algo:digest)。

$ sudo docker pull fedora
$ sudo podman create docker-daemon:docker.io/library/fedora echo hello

oci-archive:path:tag An image in a directory compliant with the “Open Container Image Layout Specification” at the specified path and specified with a tag.
oci-archive:path:tag 一个在指定路径符合“Open Container Image Layout Specification”规范的目录中,并使用标签指定的镜像。

$ podman save --format oci-archive fedora -o /tmp/fedora
$ podman create oci-archive:/tmp/fedora echo hello

OPTIONS 选项

--add-host=host:ip

Add a custom host-to-IP mapping (host:ip)
添加自定义主机到 IP 映射(host:ip)

Add a line to /etc/hosts. The format is hostname:ip. The --add-host option can be set multiple times. Conflicts with the --no-hosts option.
在 /etc/hosts 中添加一行。格式为主机名:ip。--add-host 选项可以设置多次。与 --no-hosts 选项冲突。

--annotation=key=value

Add an annotation to the container. This option can be set multiple times.
向容器添加注释。此选项可以设置多次。

--arch=ARCH

Override the architecture, defaults to hosts, of the image to be pulled. For example, arm. Unless overridden, subsequent lookups of the same image in the local storage matches this architecture, regardless of the host.
覆盖要拉取的镜像的架构,默认为主机的架构。例如, arm 。除非被覆盖,否则在本地存储中对相同镜像的后续查找将匹配此架构,而不考虑主机。

--attach, -a=stdin | stdout | stderr

Attach to STDIN, STDOUT or STDERR.
附加到标准输入、标准输出或标准错误。

In foreground mode (the default when -d is not specified), podman run can start the process in the container and attach the console to the process’s standard input, output, and error. It can even pretend to be a TTY (this is what most command-line executables expect) and pass along signals. The -a option can be set for each of stdin, stdout, and stderr.
在前台模式下(未指定 -d 时的默认模式),podman run 可以启动容器中的进程并将控制台附加到进程的标准输入、输出和错误。它甚至可以假装是一个 TTY(这是大多数命令行可执行文件所期望的),并传递信号。对于每个 stdin、stdout 和 stderr,可以设置 -a 选项。

--authfile=path

Path of the authentication file. Default is ${XDG_RUNTIME_DIR}/containers/auth.json on Linux, and $HOME/.config/containers/auth.json on Windows/macOS. The file is created by podman login. If the authorization state is not found there, $HOME/.docker/config.json is checked, which is set using docker login.
认证文件的路径。在 Linux 上默认为 ${XDG_RUNTIME_DIR}/containers/auth.json ,在 Windows/macOS 上默认为 $HOME/.config/containers/auth.json 。该文件由 podman login 创建。如果授权状态未在那里找到,则会检查 $HOME/.docker/config.json ,该值是使用 docker login 设置的。

Note: There is also the option to override the default path of the authentication file by setting the REGISTRY_AUTH_FILE environment variable. This can be done with export REGISTRY_AUTH_FILE=path.
注意:还有一种选择,可以通过设置 REGISTRY_AUTH_FILE 环境变量来覆盖认证文件的默认路径。可以通过 export REGISTRY_AUTH_FILE=path 来实现。

--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 相对设备权重。

--cap-add=capability --cap-add=capability

Add Linux capabilities. 添加 Linux 功能。

--cap-drop=capability --cap-drop=功能 ¶

Drop Linux capabilities.
删除 Linux 功能。

--cgroup-conf=KEY=VALUE

When running on cgroup v2, specify the cgroup file to write to and its value. For example --cgroup-conf=memory.high=1073741824 sets the memory.high limit to 1GB.
在 cgroup v2 上运行时,指定要写入的 cgroup 文件及其值。例如,--cgroup-conf=memory.high=1073741824 将 memory.high 限制设置为 1GB。

--cgroup-parent=path

Path to cgroups under which the cgroup for the container is created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups are created if they do not already exist.
用于创建容器的 cgroup 所在的 cgroups 路径。 如果路径不是绝对路径,则将其视为相对于 init 进程的 cgroups 路径。 如果尚不存在,则会创建 cgroups。

--cgroupns=mode

Set the cgroup namespace mode for the container.
为容器设置 cgroup 命名空间模式。

  • host: use the host’s cgroup namespace inside the container.
    host: 在容器内使用主机的 cgroup 命名空间。

  • container:id: join the namespace of the specified container.
    container:id: 加入指定容器的命名空间。

  • private: create a new cgroup namespace.
    创建一个新的 cgroup 命名空间。

  • ns:path: join the namespace at the specified path.
    ns:path: 加入到指定路径的命名空间。

If the host uses cgroups v1, the default is set to host. On cgroups v2, the default is private.
如果主机使用 cgroups v1,则默认设置为 host。在 cgroups v2 上,默认设置为 private。

--cgroups=how

Determines whether the container creates CGroups.
确定容器是否创建 CGroups。

Default is enabled. 默认为启用。

The enabled option creates a new cgroup under the cgroup-parent. The disabled option forces the container to not create CGroups, and thus conflicts with CGroup options (--cgroupns and --cgroup-parent). The no-conmon option disables a new CGroup only for the conmon process. The split option splits the current CGroup in two sub-cgroups: one for conmon and one for the container payload. It is not possible to set --cgroup-parent with split.
启用选项在 cgroup-parent 下创建一个新的 cgroup。禁用选项会强制容器不创建 CGroups,因此与 CGroup 选项 (--cgroupns 和 --cgroup-parent) 冲突。no-conmon 选项仅禁用 conmon 进程的新 CGroup。split 选项将当前的 CGroup 分成两个子 cgroup:一个用于 conmon,一个用于容器负载。无法在 split 时设置 --cgroup-parent。

--chrootdirs=path

Path to a directory inside the container that is treated as a chroot directory. Any Podman managed file (e.g., /etc/resolv.conf, /etc/hosts, etc/hostname) that is mounted into the root directory is mounted into that location as well. Multiple directories are separated with a comma.
容器内的目录路径,被视为一个 chroot 目录。任何 Podman 管理的文件(例如 /etc/resolv.conf、/etc/hosts、etc/hostname)如果被挂载到根目录,也会被挂载到这个位置。多个目录用逗号分隔。

--cidfile=file

Write the container ID to file. The file is removed along with the container, except when used with podman --remote run on detached containers.
将容器 ID 写入文件。该文件将随容器一起被删除,除非在已分离容器上使用 podman --remote run。

--conmon-pidfile=file

Write the pid of the conmon process to a file. As conmon runs in a separate process than Podman, this is necessary when using systemd to restart Podman containers. (This option is not available with the remote Podman client, including Mac and Windows (excluding WSL2) machines)
将 conmon 进程的 pid 写入文件。由于 conmon 在一个独立的进程中运行,所以在使用 systemd 重新启动 Podman 容器时,这是必要的。(此选项不适用于远程 Podman 客户端,包括 Mac 和 Windows(不包括 WSL2)机器)

--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 无根系统。

--decryption-key=key[:passphrase]

The [key[:passphrase]] to be used for decryption of images. Key can point to keys and/or certificates. Decryption is tried with all keys. If the key is protected by a passphrase, it is required to be passed in the argument and omitted otherwise.
用于解密图像的密钥[:密码]。密钥可以指向密钥和/或证书。尝试使用所有密钥进行解密。如果密钥受密码保护,则需要在参数中传递密码,否则应省略。

--device=host-device[:container-device][:permissions]
--device=主机设备[:容器设备][:权限] ¶

Add a host device to the container. Optional permissions parameter can be used to specify device permissions by combining r for read, w for write, and m for mknod(2).
将主机设备添加到容器中。可选的权限参数可用于通过组合 r 代表读取,w 代表写入,m 代表 mknod(2) 来指定设备权限。

Example: --device=/dev/sdc:/dev/xvdc:rwm.
示例: --device=/dev/sdc:/dev/xvdc:rwm.

Note: if host-device is a symbolic link then it is resolved first. The container only stores the major and minor numbers of the host device.
注意: 如果主机设备是一个符号链接,则首先解析它。容器仅存储主机设备的主次编号。

Podman may load kernel modules required for using the specified device. The devices that Podman loads modules for when necessary are: /dev/fuse.
Podman 可能会加载使用指定设备所需的内核模块。Podman 在必要时加载模块的设备有: /dev/fuse。

In rootless mode, the new device is bind mounted in the container from the host rather than Podman creating it within the container space. Because the bind mount retains its SELinux label on SELinux systems, the container can get permission denied when accessing the mounted device. Modify SELinux settings to allow containers to use all device labels via the following command:
在无根模式下,新设备是从主机中绑定挂载到容器中,而不是 Podman 在容器空间内创建它。由于绑定挂载在 SELinux 系统上保留其 SELinux 标签,当容器访问挂载的设备时可能会出现权限被拒绝的情况。通过以下命令修改 SELinux 设置以允许容器使用所有设备标签:

$ sudo setsebool -P container_use_devices=true

Note: if the user only has access rights via a group, accessing the device from inside a rootless container fails. Use the --group-add keep-groups flag to pass the user’s supplementary group access into the container.
注意:如果用户仅通过组具有访问权限,则无法从无根容器内访问设备。使用 --group-add keep-groups 标志将用户的附加组访问权限传递到容器中。

--device-cgroup-rule=”type major:minor mode”
--device-cgroup-rule=”类型 主:次 模式”

Add a rule to the cgroup allowed devices list. The rule is expected to be in the format specified in the Linux kernel documentation admin-guide/cgroup-v1/devices:
将规则添加到 cgroup 允许设备列表中。预期规则的格式应符合 Linux 内核文档 admin-guide/cgroup-v1/devices 中指定的格式:

  • type: a (all), c (char), or b (block);
    类型: a (全部), c (字符)或 b (块);

  • major and minor: either a number, or * for all;
    主设备号和次设备号: 可以是数字,或者 * 表示全部;

  • mode: a composition of r (read), w (write), and m (mknod(2)).
    模式: 由 r (读取)、 w (写入)和 m (mknod(2))组成。

--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 无根系统。

--disable-content-trust

This is a Docker-specific option to disable image verification to a container registry and is not supported by Podman. This option is a NOOP and provided solely for scripting compatibility.
这是一个 Docker 特定选项,用于禁用对容器注册表的镜像验证,不受 Podman 支持。此选项是一个 NOOP,并且仅用于脚本兼容性。

--dns=ipaddr

Set custom DNS servers.
设置自定义 DNS 服务器。

This option can be used to override the DNS configuration passed to the container. Typically this is necessary when the host DNS configuration is invalid for the container (e.g., 127.0.0.1). When this is the case the --dns flag is necessary for every run.
此选项可用于覆盖传递给容器的 DNS 配置。通常在主机 DNS 配置对容器无效时(例如,127.0.0.1)需要使用此选项。在这种情况下,每次运行都需要使用 --dns 标志。

The special value none can be specified to disable creation of /etc/resolv.conf in the container by Podman. The /etc/resolv.conf file in the image is used without changes.
可以指定特殊值 none 来禁用 Podman 在容器中创建 /etc/resolv.conf。镜像中的 /etc/resolv.conf 文件将不会更改地使用。

This option cannot be combined with --network that is set to none or container:id.
此选项不能与设置为 none 或 container:id 的 --network 结合使用。

--dns-option=option

Set custom DNS options. Invalid if using --dns-option with --network that is set to none or container:id.
设置自定义 DNS 选项。如果使用 --network 设置为 none 或 container:id 时,--dns-option 无效。

--dns-search=domain --dns-search=域名 ¶

Set custom DNS search domains. Invalid if using --dns-search with --network that is set to none or container:id. Use --dns-search=. to remove the search domain.
设置自定义 DNS 搜索域。如果使用 --network 设置为 none 或 container:id 时,--dns-search 无效。使用 --dns-search=. 可以移除搜索域。

--entrypoint=”command” | ‘[“command”, “arg1”, …]’
--entrypoint=”command” | ‘[“command”, “arg1”, …]’

Override the default ENTRYPOINT from the image.
覆盖图像的默认 ENTRYPOINT。

The ENTRYPOINT of an image is similar to a COMMAND because it specifies what executable to run when the container starts, but it is (purposely) more difficult to override. The ENTRYPOINT gives a container its default nature or behavior. When the ENTRYPOINT is set, the container runs as if it were that binary, complete with default options. More options can be passed in via the COMMAND. But, if a user wants to run something else inside the container, the --entrypoint option allows a new ENTRYPOINT to be specified.
图像的 ENTRYPOINT 类似于 COMMAND,因为它指定了容器启动时要运行的可执行文件,但故意更难覆盖。ENTRYPOINT 为容器赋予其默认性质或行为。当设置了 ENTRYPOINT 时,容器会像运行该二进制文件一样运行,包括默认选项。更多选项可以通过 COMMAND 传递。但是,如果用户想在容器内运行其他内容,--entrypoint 选项允许指定新的 ENTRYPOINT。

Specify multi option commands in the form of a json string.
以 JSON 字符串的形式指定多选项命令。

--env, -e=env

Set environment variables.
设置环境变量。

This option allows arbitrary environment variables that are available for the process to be launched inside of the container. If an environment variable is specified without a value, Podman checks the host environment for a value and set the variable only if it is set on the host. As a special case, if an environment variable ending in * is specified without a value, Podman searches the host environment for variables starting with the prefix and adds those variables to the container.
此选项允许设置可用于在容器内启动的进程的任意环境变量。如果指定环境变量而没有值,Podman 将检查主机环境以获取值,并仅在主机上设置了该变量时才设置该变量。作为特例,如果指定以 * 结尾的环境变量而没有值,Podman 将搜索主机环境以查找以该前缀开头的变量,并将这些变量添加到容器中。

See Environment note below for precedence and examples.
请参阅下面的环境说明,了解优先级和示例。

--env-file=file

Read in a line-delimited file of environment variables.
读取一个以行分隔的环境变量文件。

See Environment note below for precedence and examples.
请参阅下面的环境说明,了解优先级和示例。

--env-host

Use host environment inside of the container. See Environment note below for precedence. (This option is not available with the remote Podman client, including Mac and Windows (excluding WSL2) machines)
在容器内部使用主机环境。请参阅下面的环境说明以了解优先级。(此选项不适用于远程 Podman 客户端,包括 Mac 和 Windows(不包括 WSL2)机器)

--env-merge=env

Preprocess default environment variables for the containers. For example if image contains environment variable hello=world user can preprocess it using --env-merge hello=${hello}-some so new value is hello=world-some.
为容器预处理默认环境变量。例如,如果镜像包含环境变量 hello=world ,用户可以使用 --env-merge hello=${hello}-some 进行预处理,使新值为 hello=world-some

Please note that if the environment variable hello is not present in the image, then it’ll be replaced by an empty string and so using --env-merge hello=${hello}-some would result in the new value of hello=-some, notice the leading - delimiter.
请注意,如果镜像中不存在环境变量 hello ,那么它将被替换为空字符串,因此使用 --env-merge hello=${hello}-some 将导致 hello=-some 的新值,注意前导 - 分隔符。

--expose=port[/protocol]
--expose=端口[/协议] ¶

Expose a port or a range of ports (e.g. --expose=3300-3310). The protocol can be tcp, udp or sctp and if not given tcp is assumed. This option matches the EXPOSE instruction for image builds and has no effect on the actual networking rules unless -P/--publish-all is used to forward to all exposed ports from random host ports. To forward specific ports from the host into the container use the -p/--publish option instead.
暴露一个端口或一系列端口(例如 --expose=3300-3310)。协议可以是 tcpudpsctp ,如果未提供,则假定为 tcp 。此选项与构建镜像时的 EXPOSE 指令匹配,并且除非使用 -P/--publish-all 将所有暴露的端口转发到随机主机端口,否则不会影响实际的网络规则。要将主机的特定端口转发到容器中,请改用 -p/--publish 选项。

--gidmap=[flags]container_uid:from_uid[:amount]
--gidmap=[标志]容器 uid:从 uid[:数量] ¶

Run the container in a new user namespace using the supplied GID mapping. This option conflicts with the --userns and --subgidname options. This option provides a way to map host GIDs to container GIDs in the same way as --uidmap maps host UIDs to container UIDs. For details see --uidmap.
使用提供的 GID 映射在新的用户命名空间中运行容器。此选项与--userns 和 --subgidname 选项冲突。此选项提供了一种将主机 GID 映射到容器 GID 的方式,就像 --uidmap 将主机 UID 映射到容器 UID 一样。有关详细信息,请参阅 --uidmap。

Note: the --gidmap option cannot be called in conjunction with the --pod option as a gidmap cannot be set on the container level when in a pod.
注意:当在 Pod 中时,--gidmap 选项不能与 --pod 选项一起调用,因为在 Pod 中时无法在容器级别设置 gidmap。

--gpus=ENTRY --gpus=ENTRY

GPU devices to add to the container (‘all’ to pass all GPUs) Currently only Nvidia devices are supported.
要添加到容器中的 GPU 设备(使用 'all' 表示所有 GPU)目前仅支持 Nvidia 设备。

--group-add=group | keep-groups

Assign additional groups to the primary user running within the container process.
为运行在容器进程内的主要用户分配额外的组。

  • keep-groups is a special flag that tells Podman to keep the supplementary group access.
    keep-groups 是一个特殊标志,告诉 Podman 保持附加组访问权限。

Allows container to use the user’s supplementary group access. If file systems or devices are only accessible by the rootless user’s group, this flag tells the OCI runtime to pass the group access into the container. Currently only available with the crun OCI runtime. Note: keep-groups is exclusive, other groups cannot be specified with this flag. (Not available for remote commands, including Mac and Windows (excluding WSL2) machines)
允许容器使用用户的附加组访问权限。如果文件系统或设备仅可由无根用户组访问,则此标志告诉 OCI 运行时将组访问权限传递到容器中。目前仅适用于 crun OCI 运行时。注意: keep-groups 是独占的,其他组不能与此标志一起指定。(不适用于远程命令,包括 Mac 和 Windows(不包括 WSL2)机器)

--group-entry=ENTRY

Customize the entry that is written to the /etc/group file within the container when --user is used.
当使用 --user 时,自定义写入容器中 /etc/group 文件的条目。

The variables $GROUPNAME, $GID, and $USERLIST are automatically replaced with their value at runtime if present.
如果存在,变量$GROUPNAME、$GID 和$USERLIST 会在运行时自动替换为它们的值。

--health-cmd=”command” | ‘[“command”, “arg1”, …]’

Set or alter a healthcheck command for a container. The command is a command to be executed inside the container that determines the container health. The command is required for other healthcheck options to be applied. A value of none disables existing healthchecks.
设置或更改容器的健康检查命令。该命令是在容器内部执行的命令,用于确定容器的健康状况。该命令是应用其他健康检查选项所必需的。将值设置为 none 会禁用现有的健康检查。

Multiple options can be passed in the form of a JSON array; otherwise, the command is interpreted as an argument to /bin/sh -c.
多个选项可以以 JSON 数组的形式传递;否则,该命令将被解释为 /bin/sh -c 的参数。

--health-interval=interval

Set an interval for the healthchecks. An interval of disable results in no automatic timer setup. The default is 30s.
设置健康检查的间隔。禁用间隔会导致没有自动计时器设置。默认值为 30 秒。

--health-on-failure=action

Action to take once the container transitions to an unhealthy state. The default is none.
一旦容器转换为不健康状态,要采取的操作。默认值为无。

  • none: Take no action. 无:不采取任何操作。

  • kill: Kill the container.
    杀死:杀死容器。

  • restart: Restart the container. Do not combine the restart action with the --restart flag. When running inside of a systemd unit, consider using the kill or stop action instead to make use of systemd’s restart policy.
    重新启动:重新启动容器。不要将 restart 操作与 --restart 标志结合使用。在 systemd 单元内运行时,考虑改用 killstop 操作,以利用 systemd 的重新启动策略。

  • stop: Stop the container.
    停止:停止容器。

--health-retries=retries

The number of retries allowed before a healthcheck is considered to be unhealthy. The default value is 3.
在健康检查被视为不健康之前允许的重试次数。默认值为 3。

--health-start-period=period

The initialization time needed for a container to bootstrap. The value can be expressed in time format like 2m3s. The default value is 0s.
容器引导所需的初始化时间。该值可以用时间格式表示,如 2m3s。默认值为 0s。

Note: The health check command is executed as soon as a container is started, if the health check is successful the container’s health state will be updated to healthy. However, if the health check fails, the health state will stay as starting until either the health check is successful or until the --health-start-period time is over. If the health check command fails after the --health-start-period time is over, the health state will be updated to unhealthy. The health check command is executed periodically based on the value of --health-interval.
注意:健康检查命令会在容器启动后立即执行,如果健康检查成功,容器的健康状态将更新为 healthy 。但是,如果健康检查失败,健康状态将保持为 starting ,直到健康检查成功或 --health-start-period 时间结束为止。如果健康检查命令在 --health-start-period 时间结束后失败,健康状态将更新为 unhealthy 。健康检查命令会根据 --health-interval 的值定期执行。

--health-startup-cmd=”command” | ‘[“command”, “arg1”, …]’
--health-startup-cmd=”command” | ‘[“command”, “arg1”, …]’

Set a startup healthcheck command for a container. This command is executed inside the container and is used to gate the regular healthcheck. When the startup command succeeds, the regular healthcheck begins and the startup healthcheck ceases. Optionally, if the command fails for a set number of attempts, the container is restarted. A startup healthcheck can be used to ensure that containers with an extended startup period are not marked as unhealthy until they are fully started. Startup healthchecks can only be used when a regular healthcheck (from the container’s image or the --health-cmd option) is also set.
为容器设置启动健康检查命令。此命令在容器内部执行,用于控制常规健康检查。当启动命令成功时,常规健康检查开始,启动健康检查停止。可选地,如果命令连续失败一定次数,容器将被重新启动。启动健康检查可用于确保具有较长启动时间的容器在完全启动之前不被标记为不健康。只有在设置了常规健康检查(来自容器镜像或--health-cmd 选项)时才能使用启动健康检查。

--health-startup-interval=interval

Set an interval for the startup healthcheck. An interval of disable results in no automatic timer setup. The default is 30s.
为启动健康检查设置一个间隔。禁用间隔将导致没有自动计时器设置。默认值为 30 秒。

--health-startup-retries=retries

The number of attempts allowed before the startup healthcheck restarts the container. If set to 0, the container is never restarted. The default is 0.
在启动健康检查重新启动容器之前允许的尝试次数。如果设置为 0,则容器永远不会重新启动。默认值为 0。

--health-startup-success=retries

The number of successful runs required before the startup healthcheck succeeds and the regular healthcheck begins. A value of 0 means that any success begins the regular healthcheck. The default is 0.
在常规健康检查开始之前需要成功运行的次数。值为 0 表示任何成功都会开始常规健康检查。默认值为 0。

--health-startup-timeout=timeout

The maximum time a startup healthcheck command has to complete before it is marked as failed. The value can be expressed in a time format like 2m3s. The default value is 30s.
启动健康检查命令完成之前允许的最长时间。该值可以用类似 2m3s 的时间格式表示。默认值为 30s。

--health-timeout=timeout
--health-timeout=超时时间 ¶

The maximum time allowed to complete the healthcheck before an interval is considered failed. Like start-period, the value can be expressed in a time format such as 1m22s. The default value is 30s.
在间隔被视为失败之前,完成健康检查的最长时间。与 start-period 一样,该值可以用时间格式表示,例如 1m22s。默认值为 30s。

--help --帮助 ¶

Print usage statement 打印使用说明

--hostname, -h=name

Container host name 容器主机名

Sets the container host name that is available inside the container. Can only be used with a private UTS namespace --uts=private (default). If --pod is specified and the pod shares the UTS namespace (default) the pod’s hostname is used.
设置容器内部可用的容器主机名。只能与私有 UTS 命名空间一起使用 --uts=private (默认)。如果指定了 --pod 并且 pod 共享 UTS 命名空间(默认),则使用 pod 的主机名。

--hostuser=name

Add a user account to /etc/passwd from the host to the container. The Username or UID must exist on the host system.
将主机上的用户帐户添加到容器的 /etc/passwd 中。用户名或 UID 必须存在于主机系统上。

--http-proxy

By default proxy environment variables are passed into the container if set for the Podman process. This can be disabled by setting the value to false. The environment variables passed in include http_proxy, https_proxy, ftp_proxy, no_proxy, and also the upper case versions of those. This option is only needed when the host system must use a proxy but the container does not use any proxy. Proxy environment variables specified for the container in any other way overrides the values that have been passed through from the host. (Other ways to specify the proxy for the container include passing the values with the --env flag, or hard coding the proxy environment at container build time.) When used with the remote client it uses the proxy environment variables that are set on the server process.
默认情况下,如果为 Podman 进程设置了代理环境变量,则这些变量将传递到容器中。可以通过将值设置为 false 来禁用此功能。传递的环境变量包括 http_proxy、https_proxy、ftp_proxy、no_proxy,以及这些变量的大写版本。只有在主机系统必须使用代理但容器不使用任何代理时才需要此选项。以其他方式为容器指定的代理环境变量将覆盖从主机传递的值。(为容器指定代理的其他方式包括使用 --env 标志传递值,或在容器构建时硬编码代理环境。)与远程客户端一起使用时,它使用在服务器进程上设置的代理环境变量。

Defaults to true. 默认为真。

--image-volume=bind | tmpfs | ignore

Tells Podman how to handle the builtin image volumes. Default is bind.
告诉 Podman 如何处理内置镜像卷。默认为 bind。

  • bind: An anonymous named volume is created and mounted into the container.
    bind: 创建一个匿名命名卷并将其挂载到容器中。

  • tmpfs: The volume is mounted onto the container as a tmpfs, which allows the users to create content that disappears when the container is stopped.
    tmpfs: 该卷被挂载到容器作为 tmpfs,允许用户创建在容器停止时消失的内容。

  • ignore: All volumes are just ignored and no action is taken.
    忽略: 所有卷都被忽略,不执行任何操作。

--init

Run an init inside the container that forwards signals and reaps processes. The container-init binary is mounted at /run/podman-init. Mounting over /run breaks container execution.
在容器内运行一个 init 进程,用于转发信号并清理进程。容器的 container-init 二进制文件被挂载在 /run/podman-init 上。在 /run 上进行挂载会中断容器的执行。

--init-ctr=type

(Pods only). When using pods, create an init style container, which is run after the infra container is started but before regular pod containers are started. Init containers are useful for running setup operations for the pod’s applications.
(仅限 Pods)。在使用 Pods 时,创建一个 init 样式容器,在基础设施容器启动后运行,但在常规 Pod 容器启动之前运行。Init 容器可用于运行 Pod 应用程序的设置操作。

Valid values for init-ctr type are always or once. The always value means the container runs with each and every pod start, whereas the once value means the container only runs once when the pod is started and then the container is removed.
init-ctr 类型的有效值始终为 always 或 once。always 值表示容器随每个 pod start 运行,而 once 值表示容器仅在启动 Pod 时运行一次,然后移除容器。

Init containers are only run on pod start. Restarting a pod does not execute any init containers. Furthermore, init containers can only be created in a pod when that pod is not running.
初始化容器仅在 Pod start 上运行。重新启动 Pod 不会执行任何初始化容器。此外,只有在 Pod 未运行时才能在 Pod 中创建初始化容器。

--init-path=path

Path to the container-init binary.
容器初始化二进制文件的路径。

--interactive, -i --交互式, -i ¶

When set to true, keep stdin open even if not attached. The default is false.
当设置为 true 时,即使未连接也保持 stdin 打开。默认值为 false。

--ip=ipv4

Specify a static IPv4 address for the container, for example 10.88.64.128. This option can only be used if the container is joined to only a single network - i.e., --network=network-name is used at most once - and if the container is not joining another container’s network namespace via --network=container:id. The address must be within the network’s IP address pool (default 10.88.0.0/16).
为容器指定静态 IPv4 地址,例如 10.88.64.128。此选项仅在容器仅加入单个网络时才能使用 - 即,最多只能使用一次 --network=network-name - 并且容器不通过 --network=container:id 加入另一个容器的网络命名空间。地址必须在网络的 IP 地址池内(默认为 10.88.0.0/16)。

To specify multiple static IP addresses per container, set multiple networks using the --network option with a static IP address specified for each using the ip mode for that option.
要为每个容器指定多个静态 IP 地址,请使用 --network 选项设置多个网络,并为每个网络使用 ip 模式指定一个静态 IP 地址。

--ip6=ipv6 --ip6=ipv6

Specify a static IPv6 address for the container, for example fd46:db93:aa76:ac37::10. This option can only be used if the container is joined to only a single network - i.e., --network=network-name is used at most once - and if the container is not joining another container’s network namespace via --network=container:id. The address must be within the network’s IPv6 address pool.
为容器指定静态 IPv6 地址,例如 fd46:db93:aa76:ac37::10。只有当容器仅加入单个网络时才能使用此选项 - 即,最多只能使用一次 --network=network-name - 并且容器不通过 --network=container:id 加入另一个容器的网络命名空间。地址必须在网络的 IPv6 地址池内。

To specify multiple static IPv6 addresses per container, set multiple networks using the --network option with a static IPv6 address specified for each using the ip6 mode for that option.
要为每个容器指定多个静态 IPv6 地址,请使用 --network 选项设置多个网络,并为每个网络使用 ip6 模式指定一个静态 IPv6 地址。

--ipc=ipc --ipc=ipc

Set the IPC namespace mode for a container. The default is to create a private IPC namespace.
为容器设置 IPC 命名空间模式。默认情况下是创建一个私有 IPC 命名空间。

  • “”: Use Podman’s default, defined in containers.conf.
    “”: 使用 Podman 在 containers.conf 中定义的默认值。

  • container:id: reuses another container’s shared memory, semaphores, and message queues
    container:id: 重用另一个容器的共享内存、信号量和消息队列。

  • host: use the host’s shared memory, semaphores, and message queues inside the container. Note: the host mode gives the container full access to local shared memory and is therefore considered insecure.
    主机:在容器内使用主机的共享内存、信号量和消息队列。注意:主机模式使容器完全访问本地共享内存,因此被视为不安全。

  • none: private IPC namespace, with /dev/shm not mounted.
    无:私有 IPC 命名空间,未挂载 /dev/shm。

  • ns:path: path to an IPC namespace to join.
    ns:path:要加入的 IPC 命名空间的路径。

  • private: private IPC namespace.
    私有:私有 IPC 命名空间。

  • shareable: private IPC namespace with a possibility to share it with other containers.
    可共享:私有 IPC 命名空间,可以与其他容器共享。

--label, -l=key=value --label,-l=key=value ¶

Add metadata to a container.
向容器添加元数据。

--label-file=file

Read in a line-delimited file of labels.
读取一个以行分隔的标签文件。

--log-driver=driver

Logging driver for the container. Currently available options are k8s-file, journald, none, passthrough and passthrough-tty, with json-file aliased to k8s-file for scripting compatibility. (Default journald).
用于容器的日志驱动程序。当前可用选项包括 k8s-file、journald、none、passthrough 和 passthrough-tty,其中 json-file 别名为 k8s-file 以实现脚本兼容性。(默认为 journald)。

The podman info command below displays the default log-driver for the system.
下面的 podman info 命令显示系统的默认日志驱动程序。

$ podman info --format '{{ .Host.LogDriver }}'
journald

The passthrough driver passes down the standard streams (stdin, stdout, stderr) to the container. It is not allowed with the remote Podman client, including Mac and Windows (excluding WSL2) machines, and on a tty, since it is vulnerable to attacks via TIOCSTI.
passthrough 驱动程序将标准流(stdin、stdout、stderr)传递给容器。它在远程 Podman 客户端(包括 Mac 和 Windows(不包括 WSL2)机器)以及在 tty 上是不允许的,因为它容易受到通过 TIOCSTI 发动的攻击。

The passthrough-tty driver is the same as passthrough except that it also allows it to be used on a TTY if the user really wants it.
passthrough-tty 驱动程序与 passthrough 相同,只是它还允许在 TTY 上使用,如果用户确实希望这样做。

--log-opt=name=value

Logging driver specific options.
记录驱动程序特定选项。

Set custom logging configuration. The following names are supported:
设置自定义日志配置。支持以下名称:

path: specify a path to the log file (e.g. --log-opt path=/var/log/container/mycontainer.json);
path: 指定日志文件的路径(例如 --log-opt path=/var/log/container/mycontainer.json);

max-size: specify a max size of the log file (e.g. --log-opt max-size=10mb);
max-size: 指定日志文件的最大大小(例如 --log-opt max-size=10mb);

tag: specify a custom log tag for the container (e.g. --log-opt tag=”{{.ImageName}}”. It supports the same keys as podman inspect --format. This option is currently supported only by the journald log driver.
标签: 为容器指定自定义日志标签(例如 --log-opt tag=”{{.ImageName}}”)。它支持与 podman inspect --format 相同的键。此选项目前仅受 journald 日志驱动程序支持。

--mac-address=address

Container network interface MAC address (e.g. 92:d0:c6:0a:29:33) This option can only be used if the container is joined to only a single network - i.e., --network=network-name is used at most once - and if the container is not joining another container’s network namespace via --network=container:id.
容器网络接口的 MAC 地址(例如 92:d0:c6:0a:29:33)。只有在容器仅加入单个网络时才能使用此选项 - 即,最多只能使用一次 --network=network-name,并且容器不通过 --network=container:id 加入另一个容器的网络命名空间。

Remember that the MAC address in an Ethernet network must be unique. The IPv6 link-local address is based on the device’s MAC address according to RFC4862.
记住以太网网络中的 MAC 地址必须是唯一的。根据 RFC4862,IPv6 链路本地地址是基于设备的 MAC 地址的。

To specify multiple static MAC addresses per container, set multiple networks using the --network option with a static MAC address specified for each using the mac mode for that option.
要为每个容器指定多个静态 MAC 地址,请使用 --network 选项设置多个网络,并为每个使用 mac 模式指定一个静态 MAC 地址。

--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 根系统上受支持。

--mount=type=TYPE,TYPE-SPECIFIC-OPTION[,…]

Attach a filesystem mount to the container
将文件系统挂载到容器上

Current supported mount TYPEs are bind, devpts, glob, image, ramfs, tmpfs and volume.
当前支持的挂载类型包括 bind、devpts、glob、image、ramfs、tmpfs 和 volume。

Options common to all mount types:
所有挂载类型共同的选项:

  • src, source: mount source spec for bind, glob, and volume. Mandatory for bind and glob.
    源,来源:用于绑定、全局和卷的挂载源规范。对于绑定和全局是强制的。

  • dst, destination, target: mount destination spec.
    目的地,目标:挂载目的地规范。

When source globs are specified without the destination directory, the files and directories are mounted with their complete path within the container. When the destination is specified, the files and directories matching the glob on the base file name on the destination directory are mounted. The option type=glob,src=/foo*,destination=/tmp/bar tells container engines to mount host files matching /foo* to the /tmp/bar/ directory in the container.
当指定源全局而没有指定目的地目录时,文件和目录将以其完整路径在容器内挂载。当指定目的地时,与目的地目录上的基本文件名匹配的文件和目录将被挂载。选项 type=glob,src=/foo*,destination=/tmp/bar 告诉容器引擎将主机文件匹配到/foo*的文件挂载到容器中的/tmp/bar/目录。

Options specific to type=volume:
与 type=volume 特定的选项:

  • ro, readonly: true or false (default if unspecified: false).
    ro, readonly: true 或 false (默认值: false,如果未指定)。

  • U, chown: true or false (default if unspecified: false). Recursively change the owner and group of the source volume based on the UID and GID of the container.
    U, chown: true 或 false (默认值: false,如果未指定)。根据容器的 UID 和 GID 递归地更改源卷的所有者和组。

  • idmap: If specified, create an idmapped mount to the target user namespace in the container. The idmap option supports a custom mapping that can be different than the user namespace used by the container. The mapping can be specified after the idmap option like: idmap=uids=0-1-10#10-11-10;gids=0-100-10. For each triplet, the first value is the start of the backing file system IDs that are mapped to the second value on the host. The length of this mapping is given in the third value. Multiple ranges are separated with #. If the specified mapping is prepended with a ‘@’ then the mapping is considered relative to the container user namespace. The host ID for the mapping is changed to account for the relative position of the container user in the container user namespace.
    idmap: 如果指定,将在容器中创建一个映射到目标用户命名空间的 idmapped 挂载点。idmap 选项支持自定义映射,可以与容器使用的用户命名空间不同。映射可以在 idmap 选项之后指定,如: idmap=uids=0-1-10#10-11-10;gids=0-100-10 。对于每个三元组,第一个值是映射到主机上第二个值的后备文件系统 ID 的起始值。此映射的长度在第三个值中给出。多个范围用 # 分隔。如果指定的映射以 '@' 开头,则认为映射是相对于容器用户命名空间的。映射的主机 ID 被更改以考虑容器用户在容器用户命名空间中的相对位置。

Options specific to type=image:
特定于 type=image 的选项:

  • rw, readwrite: true or false (default if unspecified: false).
    rw, readwrite: true 或 false(如果未指定,默认值为 false)。

  • subpath: Mount only a specific path within the image, instead of the whole image.
    subpath: 仅挂载镜像中的特定路径,而不是整个镜像。

Options specific to bind and glob:
适用于 bind 和 glob 的特定选项:

  • ro, readonly: true or false (default if unspecified: false).
    ro, readonly: true 或 false(默认值为 false,如果未指定)。

  • bind-propagation: shared, slave, private, unbindable, rshared, rslave, runbindable, or rprivate (default).[1] See also mount(2).
    绑定传播: 共享, 从属, 私有, 不可解绑, 只读共享, 只读从属, 只读不可解绑, 或只读私有 (默认)。 [1] 另请参阅 mount(2)。

  • bind-nonrecursive: do not set up a recursive bind mount. By default it is recursive.
    非递归绑定: 不设置递归绑定挂载。默认情况下是递归的。

  • relabel: shared, private.
    重新标记: 共享, 私有。

  • idmap: true or false (default if unspecified: false). If true, create an idmapped mount to the target user namespace in the container.
    idmap: true 或 false(默认值如果未指定为 false)。如果为 true,则在容器中创建一个到目标用户命名空间的 idmapped 挂载。

  • U, chown: true or false (default if unspecified: false). Recursively change the owner and group of the source volume based on the UID and GID of the container.
    U,chown: true 或 false(默认值如果未指定为 false)。根据容器的 UID 和 GID 递归更改源卷的所有者和组。

  • no-dereference: do not dereference symlinks but copy the link source into the mount destination.
    no-dereference: 不解引用符号链接,而是将链接源复制到挂载目标中。

Options specific to type=tmpfs and ramfs:
适用于 type=tmpfs 和 ramfs 的特定选项:

  • ro, readonly: true or false (default if unspecified: false).
    ro, readonly: true 或 false (默认值: false)。

  • tmpfs-size: Size of the tmpfs/ramfs mount, in bytes. Unlimited by default in Linux.
    tmpfs-size: tmpfs/ramfs 挂载的大小,以字节为单位。在 Linux 中默认情况下是无限制的。

  • tmpfs-mode: Octal file mode of the tmpfs/ramfs (e.g. 700 or 0700.).
    tmpfs-mode: tmpfs/ramfs 的八进制文件模式(例如 700 或 0700)。

  • tmpcopyup: Enable copyup from the image directory at the same location to the tmpfs/ramfs. Used by default.
    tmpcopyup: 启用从相同位置的镜像目录复制到 tmpfs/ramfs。默认情况下使用。

  • notmpcopyup: Disable copying files from the image to the tmpfs/ramfs.
    notmpcopyup: 禁止从镜像复制文件到 tmpfs/ramfs。

  • U, chown: true or false (default if unspecified: false). Recursively change the owner and group of the source volume based on the UID and GID of the container.
    U,chown:true 或 false(默认值如果未指定:false)。根据容器的 UID 和 GID 递归更改源卷的所有者和组。

Options specific to type=devpts:
特定于 type=devpts 的选项:

  • uid: numeric UID of the file owner (default: 0).
    uid:文件所有者的数字 UID(默认值:0)。

  • gid: numeric GID of the file owner (default: 0).
    gid: 文件所有者的数字 GID(默认值:0)。

  • mode: octal permission mask for the file (default: 600).
    mode: 文件的八进制权限掩码(默认值:600)。

  • max: maximum number of PTYs (default: 1048576).
    max: PTY 的最大数量(默认值:1048576)。

Examples: 示例:

  • type=bind,source=/path/on/host,destination=/path/in/container

  • type=bind,src=/path/on/host,dst=/path/in/container,relabel=shared

  • type=bind,src=/path/on/host,dst=/path/in/container,relabel=shared,U=true

  • type=devpts,destination=/dev/pts

  • type=glob,src=/usr/lib/libfoo*,destination=/usr/lib,ro=true

  • type=image,source=fedora,destination=/fedora-image,rw=true

  • type=ramfs,tmpfs-size=512M,destination=/path/in/container

  • type=tmpfs,tmpfs-size=512M,destination=/path/in/container

  • type=tmpfs,destination=/path/in/container,noswap

  • type=volume,source=vol1,destination=/path/in/container,ro=true

--name=name

Assign a name to the container.
为容器指定一个名称。

The operator can identify a container in three ways:
运营商可以通过三种方式识别容器:

  • UUID long identifier (“f78375b1c487e03c9438c729345e54db9d20cfa2ac1fc3494b6eb60872e74778”);
    UUID 长标识符(“f78375b1c487e03c9438c729345e54db9d20cfa2ac1fc3494b6eb60872e74778”);

  • UUID short identifier (“f78375b1c487”);
    UUID 短标识符(“f78375b1c487”);

  • Name (“jonah”). 名称(“jonah”)。

Podman generates a UUID for each container, and if a name is not assigned to the container with --name then it generates a random string name. The name can be useful as a more human-friendly way to identify containers. This works for both background and foreground containers.
Podman 为每个容器生成一个 UUID,如果未使用--name 为容器分配名称,则会生成一个随机字符串名称。名称可作为更人性化的容器标识方式。这适用于后台和前台容器。

--network=mode, --net

Set the network mode for the container.
为容器设置网络模式。

Valid mode values are: 有效的模式值为:

  • bridge[:OPTIONS,…]: Create a network stack on the default bridge. This is the default for rootful containers. It is possible to specify these additional options:
    bridge[:OPTIONS,…]: 在默认桥接器上创建一个网络堆栈。这是 rootful 容器的默认设置。可以指定以下附加选项:

    • alias=name: Add network-scoped alias for the container.
      alias=name: 为容器添加网络范围的别名。

    • ip=IPv4: Specify a static IPv4 address for this container.
      ip=IPv4: 为此容器指定静态 IPv4 地址。

    • ip6=IPv6: Specify a static IPv6 address for this container.
      ip6=IPv6: 为此容器指定静态 IPv6 地址。

    • mac=MAC: Specify a static MAC address for this container.
      mac=MAC: 为此容器指定静态 MAC 地址。

    • interface_name=name: Specify a name for the created network interface inside the container.
      interface_name=name: 为容器内创建的网络接口指定名称。

    For example, to set a static ipv4 address and a static mac address, use --network bridge:ip=10.88.0.10,mac=44:33:22:11:00:99.
    例如,要设置静态 IPv4 地址和静态 MAC 地址,请使用 --network bridge:ip=10.88.0.10,mac=44:33:22:11:00:99

  • <network name or ID>[:OPTIONS,…]: Connect to a user-defined network; this is the network name or ID from a network created by podman network create. Using the network name implies the bridge network mode. It is possible to specify the same options described under the bridge mode above. Use the --network option multiple times to specify additional networks.
    <网络名称或 ID>[:选项,…]:连接到用户定义的网络;这是通过 podman network create 创建的网络的网络名称或 ID。使用网络名称意味着桥接网络模式。可以指定与上面的桥接模式下描述的相同选项。多次使用 --network 选项以指定其他网络。

    For backwards compatibility it is also possible to specify comma-separated networks on the first --network argument, however this prevents you from using the options described under the bridge section above.
    为了向后兼容,还可以在第一个 --network 参数上指定逗号分隔的网络,但这将阻止您使用上面桥接部分中描述的选项。

  • none: Create a network namespace for the container but do not configure network interfaces for it, thus the container has no network connectivity.
    none: 为容器创建一个网络命名空间,但不为其配置网络接口,因此容器没有网络连接。

  • container:id: Reuse another container’s network stack.
    container:id: 重用另一个容器的网络堆栈。

  • host: Do not create a network namespace, the container uses the host’s network. Note: The host mode gives the container full access to local system services such as D-bus and is therefore considered insecure.
    host: 不创建网络命名空间,容器使用主机的网络。注意:主机模式使容器完全访问本地系统服务,如 D-bus,因此被认为是不安全的。

  • ns:path: Path to a network namespace to join.
    ns:path: 加入网络命名空间的路径。

  • private: Create a new namespace for the container. This uses the bridge mode for rootful containers and slirp4netns for rootless ones.
    private: 为容器创建一个新的命名空间。对于 rootful 容器,使用桥接模式,对于 rootless 容器,使用 slirp4netns。

  • slirp4netns[:OPTIONS,…]: use slirp4netns(1) to create a user network stack. This is the default for rootless containers. It is possible to specify these additional options, they can also be set with network_cmd_options in containers.conf:
    slirp4netns[:OPTIONS,…]: 使用 slirp4netns(1) 创建用户网络堆栈。这是无根容器的默认设置。可以指定这些附加选项,它们也可以在 containers.conf 中使用 network_cmd_options 进行设置:

    • allow_host_loopback=true|false: Allow slirp4netns to reach the host loopback IP (default is 10.0.2.2 or the second IP from slirp4netns cidr subnet when changed, see the cidr option below). The default is false.
      allow_host_loopback=true|false: 允许 slirp4netns 访问主机环回 IP(默认为 10.0.2.2 或 slirp4netns cidr 子网中的第二个 IP,当更改时,请参阅下面的 cidr 选项)。默认值为 false。

    • mtu=MTU: Specify the MTU to use for this network. (Default is 65520).
      mtu=MTU: 指定此网络使用的 MTU。(默认值为 65520 )。

    • cidr=CIDR: Specify ip range to use for this network. (Default is 10.0.2.0/24).
      cidr=CIDR: 指定用于此网络的 IP 范围。(默认值为 10.0.2.0/24 )。

    • enable_ipv6=true|false: Enable IPv6. Default is true. (Required for outbound_addr6).
      enable_ipv6=true|false: 启用 IPv6。默认为 true。( outbound_addr6 所需)。

    • outbound_addr=INTERFACE: Specify the outbound interface slirp binds to (ipv4 traffic only).
      outbound_addr=INTERFACE: 指定 slirp 绑定到的出站接口(仅限 IPv4 流量)。

    • outbound_addr=IPv4: Specify the outbound ipv4 address slirp binds to.
      outbound_addr=IPv4: 指定 slirp 绑定到的出站 IPv4 地址。

    • outbound_addr6=INTERFACE: Specify the outbound interface slirp binds to (ipv6 traffic only).
      outbound_addr6=INTERFACE: 指定 slirp 绑定到的出站接口(仅限 IPv6 交通)。

    • outbound_addr6=IPv6: Specify the outbound ipv6 address slirp binds to.
      outbound_addr6=IPv6: 指定 slirp 绑定到的出站 IPv6 地址。

    • port_handler=rootlesskit: Use rootlesskit for port forwarding. Default.
      port_handler=rootlesskit: 使用 rootlesskit 进行端口转发。默认选项。

      Note: Rootlesskit changes the source IP address of incoming packets to an IP address in the container network namespace, usually 10.0.2.100. If the application requires the real source IP address, e.g. web server logs, use the slirp4netns port handler. The rootlesskit port handler is also used for rootless containers when connected to user-defined networks.
      注意:Rootlesskit 会将传入数据包的源 IP 地址更改为容器网络命名空间中的 IP 地址,通常为 10.0.2.100 。如果应用程序需要真实的源 IP 地址,例如 Web 服务器日志,请使用 slirp4netns 端口处理程序。当连接到用户定义网络时,也会使用 rootlesskit 端口处理程序。

    • port_handler=slirp4netns: Use the slirp4netns port forwarding, it is slower than rootlesskit but preserves the correct source IP address. This port handler cannot be used for user-defined networks.
      port_handler=slirp4netns:使用 slirp4netns 端口转发,速度比 rootlesskit 慢,但保留正确的源 IP 地址。此端口处理程序不能用于用户定义网络。

  • pasta[:OPTIONS,…]: use pasta(1) to create a user-mode networking stack.
    pasta[:OPTIONS,…]: 使用 pasta(1) 创建用户模式网络堆栈。

    This is only supported in rootless mode.
    这仅在无根模式下支持。

    By default, IPv4 and IPv6 addresses and routes, as well as the pod interface name, are copied from the host. If port forwarding isn’t configured, ports are forwarded dynamically as services are bound on either side (init namespace or container namespace). Port forwarding preserves the original source IP address. Options described in pasta(1) can be specified as comma-separated arguments.
    默认情况下,IPv4 和 IPv6 地址和路由以及 Pod 接口名称都从主机复制。如果未配置端口转发,则端口将在两侧绑定服务时动态转发(init 命名空间或容器命名空间)。端口转发会保留原始源 IP 地址。可以将 pasta(1)中描述的选项指定为逗号分隔的参数。

    In terms of pasta(1) options, --config-net is given by default, in order to configure networking when the container is started, and --no-map-gw is also assumed by default, to avoid direct access from container to host using the gateway address. The latter can be overridden by passing --map-gw in the pasta-specific options (despite not being an actual pasta(1) option).
    在 pasta(1)选项方面,默认情况下会提供--config-net,以便在启动容器时配置网络,并且默认情况下也会假定--no-map-gw,以避免容器直接使用网关地址访问主机。后者可以通过在 pasta 特定选项中传递--map-gw 来覆盖(尽管这不是实际的 pasta(1)选项)。

    Also, -t none and -u none are passed if, respectively, no TCP or UDP port forwarding from host to container is configured, to disable automatic port forwarding based on bound ports. Similarly, -T none and -U none are given to disable the same functionality from container to host.
    同样,如果未配置主机到容器的 TCP 或 UDP 端口转发,则分别传递 -t none 和 -u none,以禁用基于绑定端口的自动端口转发。类似地,给出 -T none 和 -U none 以禁用容器到主机的相同功能。

    Some examples: 一些例子:

    • pasta:--map-gw: Allow the container to directly reach the host using the gateway address.
      pasta:--map-gw: 允许容器直接使用网关地址访问主机。

    • pasta:--mtu,1500: Specify a 1500 bytes MTU for the tap interface in the container.
      pasta:--mtu,1500: 为容器中的 tap 接口指定一个 1500 字节的 MTU。

    • pasta:--ipv4-only,-a,10.0.2.0,-n,24,-g,10.0.2.2,--dns-forward,10.0.2.3,-m,1500,--no-ndp,--no-dhcpv6,--no-dhcp, equivalent to default slirp4netns(1) options: disable IPv6, assign 10.0.2.0/24 to the tap0 interface in the container, with gateway 10.0.2.3, enable DNS forwarder reachable at 10.0.2.3, set MTU to 1500 bytes, disable NDP, DHCPv6 and DHCP support.
      pasta:--ipv4-only,-a,10.0.2.0,-n,24,-g,10.0.2.2,--dns-forward,10.0.2.3,-m,1500,--no-ndp,--no-dhcpv6,--no-dhcp, 等同于默认的 slirp4netns(1) 选项:禁用 IPv6,在容器中为 tap0 接口分配 10.0.2.0/24 ,使用网关 10.0.2.3 ,启用可在 10.0.2.3 访问的 DNS 转发器,将 MTU 设置为 1500 字节,禁用 NDP、DHCPv6 和 DHCP 支持。

    • pasta:-I,tap0,--ipv4-only,-a,10.0.2.0,-n,24,-g,10.0.2.2,--dns-forward,10.0.2.3,--no-ndp,--no-dhcpv6,--no-dhcp, equivalent to default slirp4netns(1) options with Podman overrides: same as above, but leave the MTU to 65520 bytes
      pasta:-I,tap0,--ipv4-only,-a,10.0.2.0,-n,24,-g,10.0.2.2,--dns-forward,10.0.2.3,--no-ndp,--no-dhcpv6,--no-dhcp, 等同于默认的 slirp4netns(1) 选项,但具有 Podman 覆盖:与上述相同,但将 MTU 保留为 65520 字节。

    • pasta:-t,auto,-u,auto,-T,auto,-U,auto: enable automatic port forwarding based on observed bound ports from both host and container sides
      pasta:-t,auto,-u,auto,-T,auto,-U,auto: 根据主机和容器双方观察到的绑定端口启用自动端口转发

    • pasta:-T,5201: enable forwarding of TCP port 5201 from container to host, using the loopback interface instead of the tap interface for improved performance
      pasta:-T,5201: 启用将容器中的 TCP 端口 5201 转发到主机,使用环回接口而不是 tap 接口以提高性能

Invalid if using --dns, --dns-option, or --dns-search with --network set to none or container:id.
如果使用 --network 设置为 none 或 container:id 时,使用 --dns、--dns-option 或 --dns-search 无效。

If used together with --pod, the container does not join the pod’s network namespace.
如果与 --pod 一起使用,则容器不会加入 pod 的网络命名空间。

--network-alias=alias

Add a network-scoped alias for the container, setting the alias for all networks that the container joins. To set a name only for a specific network, use the alias option as described under the --network option. If the network has DNS enabled (podman network inspect -f {{.DNSEnabled}} <name>), these aliases can be used for name resolution on the given network. This option can be specified multiple times. NOTE: When using CNI a container only has access to aliases on the first network that it joins. This limitation does not exist with netavark/aardvark-dns.
为容器添加一个网络范围的别名,为容器加入的所有网络设置别名。要仅为特定网络设置名称,请使用别名选项,如在 --network 选项下所述。如果网络启用了 DNS( podman network inspect -f {{.DNSEnabled}} <name> ),则这些别名可用于在给定网络上进行名称解析。此选项可以指定多次。注意:使用 CNI 时,容器仅能访问它加入的第一个网络上的别名。这种限制在 netavark/aardvark-dns 中不存在。

--no-healthcheck

Disable any defined healthchecks for container.
禁用容器的任何已定义的健康检查。

--no-hosts

Do not create /etc/hosts for the container. By default, Podman manages /etc/hosts, adding the container’s own IP address and any hosts from --add-host. --no-hosts disables this, and the image’s /etc/hosts is preserved unmodified.
不为容器创建 /etc/hosts。默认情况下,Podman 管理 /etc/hosts,添加容器自己的 IP 地址和任何来自 --add-host 的主机。--no-hosts 禁用此功能,镜像的 /etc/hosts 将保持不变。

This option conflicts with --add-host.
此选项与 --add-host 冲突。

--oom-kill-disable

Whether to disable OOM Killer for the container or not.
是否禁用容器的 OOM Killer。

This flag is not supported on cgroups V2 systems.
此标志在 cgroups V2 系统上不受支持。

--oom-score-adj=num

Tune the host’s OOM preferences for containers (accepts values from -1000 to 1000).
为容器调整主机的 OOM 偏好设置(接受从-1000 到 1000 的值)。

When running in rootless mode, the specified value can’t be lower than the oom_score_adj for the current process. In this case, the oom-score-adj is clamped to the current process value.
在以无根用户模式运行时,指定的值不能低于当前进程的 oom_score_adj。在这种情况下,oom-score-adj 将被限制为当前进程的值。

--os=OS --os=操作系统 ¶

Override the OS, defaults to hosts, of the image to be pulled. For example, windows. Unless overridden, subsequent lookups of the same image in the local storage matches this OS, regardless of the host.
覆盖要拉取的镜像的操作系统,默认为主机。例如, windows 。除非被覆盖,否则在本地存储中对相同镜像的后续查找将匹配此操作系统,而不考虑主机。

--passwd-entry=ENTRY --passwd-entry=条目 ¶

Customize the entry that is written to the /etc/passwd file within the container when --passwd is used.
自定义在使用 --passwd 时写入容器中 /etc/passwd 文件的条目。

The variables $USERNAME, $UID, $GID, $NAME, $HOME are automatically replaced with their value at runtime.
变量$USERNAME、$UID、$GID、$NAME、$HOME 会在运行时自动替换为它们的值。

--personality=persona

Personality sets the execution domain via Linux personality(2).
个性通过 Linux 个性(2) 设置执行域。

--pid=mode

Set the PID namespace mode for the container. The default is to create a private PID namespace for the container.
为容器设置 PID 命名空间模式。默认情况下,为容器创建私有 PID 命名空间。

  • container:id: join another container’s PID namespace;
    容器:id: 加入另一个容器的 PID 命名空间;

  • host: use the host’s PID namespace for the container. Note the host mode gives the container full access to local PID and is therefore considered insecure;
    主机: 使用容器的主机 PID 命名空间。请注意,主机模式使容器完全访问本地 PID,并因此被视为不安全;

  • ns:path: join the specified PID namespace;
    ns:path: 加入指定的 PID 命名空间;

  • private: create a new namespace for the container (default).
    private: 为容器创建一个新的命名空间(默认)。

--pidfile=path

When the pidfile location is specified, the container process’ PID is written to the pidfile. (This option is not available with the remote Podman client, including Mac and Windows (excluding WSL2) machines) If the pidfile option is not specified, the container process’ PID is written to /run/containers/storage/${storage-driver}-containers/$CID/userdata/pidfile.
当指定了 pidfile 位置时,容器进程的 PID 将被写入到 pidfile 中。(此选项不适用于远程 Podman 客户端,包括 Mac 和 Windows(不包括 WSL2)机器)如果未指定 pidfile 选项,则容器进程的 PID 将被写入到 /run/containers/storage/${storage-driver}-containers/$CID/userdata/pidfile 中。

After the container is started, the location for the pidfile can be discovered with the following podman inspect command:
容器启动后,可以使用以下 podman inspect 命令来查找 pidfile 的位置:

$ podman inspect --format '{{ .PidFile }}' $CID
/run/containers/storage/${storage-driver}-containers/$CID/userdata/pidfile

--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。

--platform=OS/ARCH

Specify the platform for selecting the image. (Conflicts with --arch and --os) The --platform option can be used to override the current architecture and operating system. Unless overridden, subsequent lookups of the same image in the local storage matches this platform, regardless of the host.
指定用于选择镜像的平台。(与 --arch 和 --os 冲突) --platform 选项可用于覆盖当前的架构和操作系统。除非被覆盖,否则在本地存储中对相同镜像的后续查找将匹配此平台,而不考虑主机。

--pod=name --pod=名称 ¶

Run container in an existing pod. Podman makes the pod automatically if the pod name is prefixed with new:. To make a pod with more granular options, use the podman pod create command before creating a container. When a container is run with a pod with an infra-container, the infra-container is started first.
在现有的 pod 中运行容器。如果 pod 名称以 new: 为前缀,Podman 会自动创建该 pod。要使用更精细的选项创建一个 pod,请在创建容器之前使用 podman pod create 命令。当一个容器与一个 infra-container 的 pod 一起运行时,infra-container 会首先启动。

--pod-id-file=file

Run container in an existing pod and read the pod’s ID from the specified file. When a container is run within a pod which has an infra-container, the infra-container starts first.
在现有的 pod 中运行容器,并从指定文件中读取 pod 的 ID。当在具有基础设施容器的 pod 中运行容器时,基础设施容器首先启动。

--privileged

Give extended privileges to this container. The default is false.
给予此容器扩展权限。默认值为 false。

By default, Podman containers are unprivileged (=false) and cannot, for example, modify parts of the operating system. This is because by default a container is only allowed limited access to devices. A “privileged” container is given the same access to devices as the user launching the container, with the exception of virtual consoles (/dev/tty\d+) when running in systemd mode (--systemd=always).
默认情况下,Podman 容器是非特权的(=false),例如,不能修改操作系统的部分。这是因为默认情况下容器只被允许有限的设备访问权限。一个“特权”容器被赋予与启动容器的用户相同的设备访问权限,但在 systemd 模式(--systemd=always)下运行时除了虚拟控制台(/dev/tty\d+)。

A privileged container turns off the security features that isolate the container from the host. Dropped Capabilities, limited devices, read-only mount points, Apparmor/SELinux separation, and Seccomp filters are all disabled. Due to the disabled security features, the privileged field should almost never be set as containers can easily break out of confinement.
特权容器关闭了将容器与主机隔离的安全功能。已禁用了已丢弃的功能、有限的设备、只读挂载点、Apparmor/SELinux 分离和 Seccomp 过滤器。由于已禁用的安全功能,几乎永远不应该设置特权字段,因为容器很容易突破限制。

Containers running in a user namespace (e.g., rootless containers) cannot have more privileges than the user that launched them.
在用户命名空间中运行的容器(例如,无根容器)不能拥有比启动它们的用户更多的特权。

--publish, -p=[[ip:][hostPort]:]containerPort[/protocol]

Publish a container’s port, or range of ports, to the host.
将容器的端口或端口范围发布到主机。

Both hostPort and containerPort can be specified as a range of ports. When specifying ranges for both, the number of container ports in the range must match the number of host ports in the range.
hostPort 和 containerPort 都可以指定为端口范围。当同时为两者指定范围时,范围内的容器端口数量必须与主机端口数量相匹配。

If host IP is set to 0.0.0.0 or not set at all, the port is bound on all IPs on the host.
如果主机 IP 设置为 0.0.0.0 或根本未设置,则端口将绑定在主机上的所有 IP 上。

By default, Podman publishes TCP ports. To publish a UDP port instead, give udp as protocol. To publish both TCP and UDP ports, set --publish twice, with tcp, and udp as protocols respectively. Rootful containers can also publish ports using the sctp protocol.
默认情况下,Podman 发布 TCP 端口。要代替发布 UDP 端口,请将 udp 设置为协议。要同时发布 TCP 和 UDP 端口,请分别设置 --publish 两次,分别使用 tcpudp 作为协议。Rootful 容器也可以使用 sctp 协议发布端口。

Host port does not have to be specified (e.g. podman run -p 127.0.0.1::80). If it is not, the container port is randomly assigned a port on the host.
主机端口不需要指定(例如 podman run -p 127.0.0.1::80 )。如果不指定,容器端口将在主机上随机分配一个端口。

Use podman port to see the actual mapping: podman port $CONTAINER $CONTAINERPORT.
使用 podman port 命令查看实际映射: podman port $CONTAINER $CONTAINERPORT

Note that the network drivers macvlan and ipvlan do not support port forwarding, it will have no effect on these networks.
请注意,网络驱动程序 macvlanipvlan 不支持端口转发,在这些网络上不会产生任何影响。

Note: If a container runs within a pod, it is not necessary to publish the port for the containers in the pod. The port must only be published by the pod itself. Pod network stacks act like the network stack on the host - when there are a variety of containers in the pod, and programs in the container, all sharing a single interface and IP address, and associated ports. If one container binds to a port, no other container can use that port within the pod while it is in use. Containers in the pod can also communicate over localhost by having one container bind to localhost in the pod, and another connect to that port.
注意:如果容器在一个 pod 中运行,则不需要为 pod 中的容器发布端口。端口只需由 pod 本身发布。Pod 网络堆栈的作用类似于主机上的网络堆栈 - 当 pod 中有各种容器和容器中的程序时,它们都共享一个单一的接口和 IP 地址,以及相关的端口。如果一个容器绑定到一个端口,那么在使用时,pod 中的其他容器就不能使用该端口。Pod 中的容器也可以通过一个容器绑定到 pod 中的 localhost,并且另一个连接到该端口来进行通信。

--publish-all, -P

Publish all exposed ports to random ports on the host interfaces. The default is false.
将所有暴露的端口发布到主机接口上的随机端口。默认值为 false。

When set to true, publish all exposed ports to the host interfaces. If the operator uses -P (or -p) then Podman makes the exposed port accessible on the host and the ports are available to any client that can reach the host.
当设置为 true 时,将所有暴露的端口发布到主机接口。如果操作员使用-P(或-p),那么 Podman 会使暴露的端口在主机上可访问,并且这些端口对任何可以访问主机的客户端都是可用的。

When using this option, Podman binds any exposed port to a random port on the host within an ephemeral port range defined by /proc/sys/net/ipv4/ip_local_port_range. To find the mapping between the host ports and the exposed ports, use podman port.
使用此选项时,Podman 将任何暴露的端口绑定到主机上的一个随机端口,该端口位于由/proc/sys/net/ipv4/ip_local_port_range 定义的临时端口范围内。要查找主机端口和暴露端口之间的映射,请使用 podman port。

--pull=policy

Pull image policy. The default is missing.
拉取图像策略。默认值为 missing。

  • always: Always pull the image and throw an error if the pull fails.
    always: 始终拉取镜像,并在拉取失败时抛出错误。

  • missing: Pull the image only when the image is not in the local containers storage. Throw an error if no image is found and the pull fails.
    缺失: 仅在本地容器存储中不存在图像时才拉取图像。如果未找到图像且拉取失败,则抛出错误。

  • never: Never pull the image but use the one from the local containers storage. Throw an error if no image is found.
    从不: 从本地容器存储中使用现有图像,而不拉取新图像。如果未找到图像,则抛出错误。

  • newer: Pull if the image on the registry is newer than the one in the local containers storage. An image is considered to be newer when the digests are different. Comparing the time stamps is prone to errors. Pull errors are suppressed if a local image was found.
    较新:如果注册表上的图像比本地容器存储中的图像更新,则拉取。当摘要不同时,图像被视为更新。比较时间戳容易出错。如果找到本地图像,则拉取错误会被抑制。

--quiet, -q

Suppress output information when pulling images
在拉取图像时抑制输出信息。

--rdt-class=intel-rdt-class-of-service
--rdt-class=intel-rdt-class-of-service

Rdt-class sets the class of service (CLOS or COS) for the container to run in. Based on the Cache Allocation Technology (CAT) feature that is part of Intel’s Resource Director Technology (RDT) feature set, all container processes will run within the pre-configured COS, representing a part of the cache. The COS has to be created and configured using a pseudo file system (usually mounted at /sys/fs/resctrl) that the resctrl kernel driver provides. Assigning the container to a COS requires root privileges and thus doesn’t work in a rootless environment. Currently, the feature is only supported using runc as a runtime. See https://docs.kernel.org/arch/x86/resctrl.html for more details on creating a COS before a container can be assigned to it.
Rdt-class 设置容器运行的服务类别(CLOS 或 COS)。基于英特尔资源总监技术(RDT)功能集的一部分,即缓存分配技术(CAT)功能,所有容器进程将在预配置的 COS 中运行,代表缓存的一部分。必须使用伪文件系统(通常挂载在 /sys/fs/resctrl )来创建和配置 COS,该文件系统由 resctrl 内核驱动程序提供。将容器分配给 COS 需要 root 权限,因此在无 root 环境中无法工作。目前,该功能仅支持使用 runc 作为运行时。在将容器分配给 COS 之前,请参阅 https://docs.kernel.org/arch/x86/resctrl.html 了解有关创建 COS 的更多详细信息。

--read-only

Mount the container’s root filesystem as read-only.
将容器的根文件系统挂载为只读。

By default, container root filesystems are writable, allowing processes to write files anywhere. By specifying the --read-only flag, the containers root filesystem are mounted read-only prohibiting any writes.
默认情况下,容器的根文件系统是可写的,允许进程在任何地方写文件。通过指定 --read-only 标志,容器的根文件系统被挂载为只读,禁止任何写操作。

--read-only-tmpfs

When running --read-only containers, mount a read-write tmpfs on /dev, /dev/shm, /run, /tmp, and /var/tmp. The default is true.
在运行 --read-only 容器时,在 /dev、/dev/shm、/run、/tmp 和 /var/tmp 上挂载一个读写的 tmpfs。默认值为 true。

--read-only

--read-only-tmpfs

/

/run, /tmp, /var/tmp /运行,/临时,/变量/临时

true

true

r/o

r/w

true

false

r/o

r/o

false

false

r/w

r/w

false

true

r/w

r/w

When --read-only=true and --read-only-tmpfs=true additional tmpfs are mounted on the /tmp, /run, and /var/tmp directories.
当 --read-only=true 和 --read-only-tmpfs=true 时,额外的 tmpfs 被挂载到 /临时,/运行 和 /变量/临时 目录上。

When --read-only=true and --read-only-tmpfs=false /dev and /dev/shm are marked Read/Only and no tmpfs are mounted on /tmp, /run and /var/tmp. The directories are exposed from the underlying image, meaning they are read-only by default. This makes the container totally read-only. No writable directories exist within the container. In this mode writable directories need to be added via external volumes or mounts.
当 --read-only=true 和 --read-only-tmpfs=false 时,/设备 和 /设备/共享内存 被标记为只读,并且没有 tmpfs 被挂载到 /临时,/运行 和 /变量/临时 上。这些目录是从底层镜像中暴露出来的,这意味着它们默认是只读的。这使得容器完全只读。容器内部不存在可写目录。在这种模式下,可写目录需要通过外部卷或挂载添加。

By default, when --read-only=false, the /dev and /dev/shm are read/write, and the /tmp, /run, and /var/tmp are read/write directories from the container image.
默认情况下,当 --read-only=false 时,/dev 和 /dev/shm 是可读写的,而 /tmp、/run 和 /var/tmp 是容器镜像中的可读写目录。

--replace --替换 ¶

If another container with the same name already exists, replace and remove it. The default is false.
如果已经存在同名的另一个容器,则替换并移除它。默认值为 false。

--requires=container --requires=container

Specify one or more requirements. A requirement is a dependency container that is started before this container. Containers can be specified by name or ID, with multiple containers being separated by commas.
指定一个或多个要求。 要求是在此容器之前启动的依赖容器。 可以通过名称或 ID 指定容器,多个容器之间用逗号分隔。

--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)。

--retry=attempts

Number of times to retry pulling or pushing images between the registry and local storage in case of failure. Default is 3.
在发生失败时,重试在注册表和本地存储之间拉取或推送镜像的次数。默认值为 3。

--retry-delay=duration --retry-delay=持续时间 ¶

Duration of delay between retry attempts when pulling or pushing images between the registry and local storage in case of failure. The default is to start at two seconds and then exponentially back off. The delay is used when this value is set, and no exponential back off occurs.
在发生失败时,拉取或推送镜像在注册表和本地存储之间重试尝试之间的延迟持续时间。默认值是从两秒开始,然后指数级地减少。当设置了此值且没有指数级减少时,将使用延迟。

--rm

Automatically remove the container and any anonymous unnamed volume associated with the container when it exits. The default is false.
当容器退出时自动删除容器和与容器关联的任何匿名未命名卷。默认值为 false。

--rootfs

If specified, the first argument refers to an exploded container on the file system.
如果指定了,第一个参数是指文件系统上的一个解压缩的容器。

This is useful to run a container without requiring any image management, the rootfs of the container is assumed to be managed externally.
这对于运行一个容器而无需任何镜像管理很有用,容器的 rootfs 被假定为在外部管理。

Overlay Rootfs Mounts

The :O flag tells Podman to mount the directory from the rootfs path as storage using the overlay file system. The container processes can modify content within the mount point which is stored in the container storage in a separate directory. In overlay terms, the source directory is the lower, and the container storage directory is the upper. Modifications to the mount point are destroyed when the container finishes executing, similar to a tmpfs mount point being unmounted.
:O 标志告诉 Podman 使用 overlay file system 将目录从 rootfs 路径挂载为存储。容器进程可以修改挂载点内的内容,这些内容存储在容器存储中的一个单独目录中。在叠加术语中,源目录是下层,容器存储目录是上层。对挂载点的修改在容器执行完成时被销毁,类似于 tmpfs 挂载点被卸载时的情况。

Note: On SELinux systems, the rootfs needs the correct label, which is by default unconfined_u:object_r:container_file_t:s0.
注意:在 SELinux 系统上,rootfs 需要具有正确的标签,默认为 unconfined_u:object_r:container_file_t:s0。

idmap

If idmap is specified, create an idmapped mount to the target user namespace in the container. The idmap option supports a custom mapping that can be different than the user namespace used by the container. The mapping can be specified after the idmap option like: idmap=uids=0-1-10#10-11-10;gids=0-100-10. For each triplet, the first value is the start of the backing file system IDs that are mapped to the second value on the host. The length of this mapping is given in the third value. Multiple ranges are separated with #.
如果指定了 idmap ,则在容器中为目标用户命名空间创建一个 idmapped 挂载。idmap 选项支持自定义映射,可以与容器使用的用户命名空间不同。映射可以在 idmap 选项之后指定,如: idmap=uids=0-1-10#10-11-10;gids=0-100-10 。对于每个三元组,第一个值是映射到主机上第二个值的支持文件系统 ID 的起始值。此映射的长度在第三个值中给出。多个范围用 # 分隔。

--sdnotify=container | conmon | healthy | ignore

Determines how to use the NOTIFY_SOCKET, as passed with systemd and Type=notify.
确定如何使用 NOTIFY_SOCKET,与 systemd 和 Type=notify 一起传递。

Default is container, which means allow the OCI runtime to proxy the socket into the container to receive ready notification. Podman sets the MAINPID to conmon’s pid. The conmon option sets MAINPID to conmon’s pid, and sends READY when the container has started. The socket is never passed to the runtime or the container. The healthy option sets MAINPID to conmon’s pid, and sends READY when the container has turned healthy; requires a healthcheck to be set. The socket is never passed to the runtime or the container. The ignore option removes NOTIFY_SOCKET from the environment for itself and child processes, for the case where some other process above Podman uses NOTIFY_SOCKET and Podman does not use it.
默认值为 container,这意味着允许 OCI 运行时代理套接字到容器中以接收就绪通知。Podman 将 MAINPID 设置为 conmon 的 pid。conmon 选项将 MAINPID 设置为 conmon 的 pid,并在容器启动后发送 READY。套接字永远不会传递给运行时或容器。healthy 选项将 MAINPID 设置为 conmon 的 pid,并在容器变为健康状态时发送 READY;需要设置健康检查。套接字永远不会传递给运行时或容器。ignore 选项会从环境中删除 NOTIFY_SOCKET 自身和子进程,以防 Podman 上方的其他进程使用 NOTIFY_SOCKET 而 Podman 不使用它。

--seccomp-policy=policy

Specify the policy to select the seccomp profile. If set to image, Podman looks for a “io.containers.seccomp.profile” label in the container-image config and use its value as a seccomp profile. Otherwise, Podman follows the default policy by applying the default profile unless specified otherwise via --security-opt seccomp as described below.
指定选择 seccomp 配置文件的策略。如果设置为 image,Podman 将在容器镜像配置中查找“io.containers.seccomp.profile”标签,并将其值用作 seccomp 配置文件。否则,Podman 将遵循默认策略,通过应用默认配置文件,除非通过下面描述的 --security-opt seccomp 指定其他方式。

Note that this feature is experimental and may change in the future.
请注意,此功能属于实验性质,可能会在将来更改。

--secret=secret[,opt=opt …]

Give the container access to a secret. Can be specified multiple times.
将容器访问权限授予一个秘密。可以多次指定。

A secret is a blob of sensitive data which a container needs at runtime but is not stored in the image or in source control, such as usernames and passwords, TLS certificates and keys, SSH keys or other important generic strings or binary content (up to 500 kb in size).
秘密是容器在运行时需要但不存储在镜像或源代码控制中的敏感数据块,例如用户名和密码、TLS 证书和密钥、SSH 密钥或其他重要的通用字符串或二进制内容(最大 500 kb)。

When secrets are specified as type mount, the secrets are copied and mounted into the container when a container is created. When secrets are specified as type env, the secret is set as an environment variable within the container. Secrets are written in the container at the time of container creation, and modifying the secret using podman secret commands after the container is created affects the secret inside the container.
当将秘密指定为类型 mount 时,在创建容器时,秘密将被复制并挂载到容器中。当将秘密指定为类型 env 时,秘密将作为容器内的环境变量设置。秘密在容器创建时写入容器,使用 podman secret 命令在容器创建后修改秘密会影响容器内的秘密。

Secrets and its storage are managed using the podman secret command.
使用 podman secret 命令管理秘密及其存储。

Secret Options 秘密选项

  • type=mount|env : How the secret is exposed to the container. mount mounts the secret into the container as a file. env exposes the secret as an environment variable. Defaults to mount.
    type=mount|env :如何将秘密暴露给容器。 mount 将秘密挂载到容器中作为文件。 env 将秘密暴露为环境变量。默认为 mount

  • target=target : Target of secret. For mounted secrets, this is the path to the secret inside the container. If a fully qualified path is provided, the secret is mounted at that location. Otherwise, the secret is mounted to /run/secrets/target for linux containers or /var/run/secrets/target for freebsd containers. If the target is not set, the secret is mounted to /run/secrets/secretname by default. For env secrets, this is the environment variable key. Defaults to secretname.
    target=target :秘密的目标。对于已挂载的秘密,这是容器内秘密的路径。如果提供了完全合格的路径,秘密将挂载到该位置。否则,秘密将挂载到 /run/secrets/target (Linux 容器)或 /var/run/secrets/target (FreeBSD 容器)。如果未设置目标,则默认将秘密挂载到 /run/secrets/secretname 。对于环境变量秘密,这是环境变量键。默认为 secretname

  • uid=0 : UID of secret. Defaults to 0. Mount secret type only.
    uid=0 :秘密的 UID。默认为 0。仅适用于挂载秘密类型。

  • gid=0 : GID of secret. Defaults to 0. Mount secret type only.
    gid=0 :秘密的 GID。默认为 0。仅挂载秘密类型。

  • mode=0 : Mode of secret. Defaults to 0444. Mount secret type only.
    mode=0 :秘密的模式。默认为 0444。仅挂载秘密类型。

Examples 示例

Mount at /my/location/mysecret with UID 1:
/my/location/mysecret 处挂载,UID 1:

--secret mysecret,target=/my/location/mysecret,uid=1

Mount at /run/secrets/customtarget with mode 0777:
/run/secrets/customtarget 处以 0777 模式挂载:

--secret mysecret,target=customtarget,mode=0777

Create a secret environment variable called ENVSEC:
创建一个名为 ENVSEC 的秘密环境变量:

--secret mysecret,type=env,target=ENVSEC

--security-opt=option --security-opt=option

Security Options 安全选项

  • apparmor=unconfined : Turn off apparmor confinement for the container
    apparmor=unconfined:为容器关闭 apparmor 限制

  • apparmor=alternate-profile : Set the apparmor confinement profile for the container
    apparmor=alternate-profile:为容器设置 apparmor 限制配置文件

  • label=user:USER: Set the label user for the container processes
    label=user:USER:为容器进程设置用户标签

  • label=role:ROLE: Set the label role for the container processes
    标签=角色: 为容器进程设置标签角色

  • label=type:TYPE: Set the label process type for the container processes
    标签=类型: 为容器进程设置标签进程类型

  • label=level:LEVEL: Set the label level for the container processes
    标签=级别: 为容器进程设置标签级别

  • label=filetype:TYPE: Set the label file type for the container files
    标签=filetype:类型: 为容器文件设置标签文件类型

  • label=disable: Turn off label separation for the container
    标签=disable: 关闭容器的标签分离

Note: Labeling can be disabled for all containers by setting label=false in the containers.conf (/etc/containers/containers.conf or $HOME/.config/containers/containers.conf) file.
注意: 可以通过在 containers.conf ( /etc/containers/containers.conf$HOME/.config/containers/containers.conf ) 文件中设置 label=false 来禁用所有容器的标签化。

  • label=nested: Allows SELinux modifications within the container. Containers are allowed to modify SELinux labels on files and processes, as long as SELinux policy allows. Without nested, containers view SELinux as disabled, even when it is enabled on the host. Containers are prevented from setting any labels.
    label=nested: 允许容器内进行 SELinux 修改。只要 SELinux 策略允许,容器就可以修改文件和进程的 SELinux 标签。没有嵌套,容器会将 SELinux 视为已禁用,即使在主机上已启用。容器被阻止设置任何标签。

  • mask=/path/1:/path/2: The paths to mask separated by a colon. A masked path cannot be accessed inside the container.
    mask=/path/1:/path/2: 由冒号分隔的要屏蔽的路径。在容器内无法访问被屏蔽的路径。

  • no-new-privileges: Disable container processes from gaining additional privileges.
    no-new-privileges: 禁止容器进程获取额外的特权。

  • seccomp=unconfined: Turn off seccomp confinement for the container.
    seccomp=unconfined:关闭容器的 seccomp 限制。

  • seccomp=profile.json: JSON file to be used as a seccomp filter. Note that the io.podman.annotations.seccomp annotation is set with the specified value as shown in podman inspect.
    seccomp=profile.json:要用作 seccomp 过滤器的 JSON 文件。请注意, io.podman.annotations.seccomp 注释将设置为所示的指定值。

  • proc-opts=OPTIONS : Comma-separated list of options to use for the /proc mount. More details for the possible mount options are specified in the proc(5) man page.
    proc-opts=OPTIONS:用于 /proc 挂载的逗号分隔选项列表。有关可能的挂载选项的更多详细信息,请参阅 proc(5) 手册页。

  • unmask=ALL or /path/1:/path/2, or shell expanded paths (/proc/*): Paths to unmask separated by a colon. If set to ALL, it unmasks all the paths that are masked or made read-only by default. The default masked paths are /proc/acpi, /proc/kcore, /proc/keys, /proc/latency_stats, /proc/sched_debug, /proc/scsi, /proc/timer_list, /proc/timer_stats, /sys/firmware, and /sys/fs/selinux, /sys/devices/virtual/powercap. The default paths that are read-only are /proc/asound, /proc/bus, /proc/fs, /proc/irq, /proc/sys, /proc/sysrq-trigger, /sys/fs/cgroup.
    unmask=ALL 或/path/1:/path/2,或 shell 扩展路径(/proc/*):以冒号分隔的要解除掩码的路径。如果设置为 ALL,则解除掩码或默认情况下设置为只读的所有路径。默认的掩码路径包括/proc/acpi、/proc/kcore、/proc/keys、/proc/latency_stats、/proc/sched_debug、/proc/scsi、/proc/timer_list、/proc/timer_stats、/sys/firmware 和/sys/fs/selinux、/sys/devices/virtual/powercap。默认的只读路径包括/proc/asound、/proc/bus、/proc/fs、/proc/irq、/proc/sys、/proc/sysrq-trigger、/sys/fs/cgroup。

Note: Labeling can be disabled for all containers by setting label=false in the containers.conf(5) file.
注意:可以通过在 containers.conf(5)文件中设置 label=false 来禁用所有容器的标签。

--shm-size=number[unit]
--shm-size=number[unit]

Size of /dev/shm. A unit can be b (bytes), k (kibibytes), m (mebibytes), or g (gibibytes). If the unit is omitted, the system uses bytes. If the size is omitted, the default is 64m. When size is 0, there is no limit on the amount of memory used for IPC by the container. This option conflicts with --ipc=host.
/dev/shm 的大小。单位可以是 b(字节)、k(kibibytes)、m(mebibytes)或 g(gibibytes)。如果省略单位,则系统使用字节。如果省略大小,则默认为 64m。当大小为 0 时,容器使用的 IPC 内存量没有限制。此选项与 --ipc=host 冲突。

--shm-size-systemd=number[unit]
--shm-size-systemd=数字[unit]

Size of systemd-specific tmpfs mounts such as /run, /run/lock, /var/log/journal and /tmp. A unit can be b (bytes), k (kibibytes), m (mebibytes), or g (gibibytes). If the unit is omitted, the system uses bytes. If the size is omitted, the default is 64m. When size is 0, the usage is limited to 50% of the host’s available memory.
systemd 特定 tmpfs 挂载的大小,例如 /run、/run/lock、/var/log/journal 和 /tmp。单位可以是 b(字节)、k(kibibytes)、m(mebibytes)或 g(gibibytes)。如果省略单位,则系统使用字节。如果省略大小,则默认为 64m。当大小为 0 时,使用量限制为主机可用内存的 50%。

--stop-signal=signal

Signal to stop a container. Default is SIGTERM.
停止容器的信号。默认为 SIGTERM。

--stop-timeout=seconds --停止超时=秒 ¶

Timeout to stop a container. Default is 10. Remote connections use local containers.conf for defaults.
停止容器的超时时间。默认值为 10。远程连接使用本地 containers.conf 的默认值。

--subgidname=name --subgidname=名称 ¶

Run the container in a new user namespace using the map with name in the /etc/subgid file. If running rootless, the user needs to have the right to use the mapping. See subgid(5). This flag conflicts with --userns and --gidmap.
在新的用户命名空间中使用 /etc/subgid 文件中的名称映射来运行容器。如果以 rootless 模式运行,则用户需要有使用映射的权限。请参阅 subgid(5)。此标志与 --userns 和 --gidmap 冲突。

--subuidname=name

Run the container in a new user namespace using the map with name in the /etc/subuid file. If running rootless, the user needs to have the right to use the mapping. See subuid(5). This flag conflicts with --userns and --uidmap.
在新的用户命名空间中使用 /etc/subuid 文件中的名称映射来运行容器。如果以 rootless 模式运行,则用户需要有使用映射的权限。请参阅 subuid(5)。此标志与 --userns 和 --uidmap 冲突。

--sysctl=name=value

Configure namespaced kernel parameters at runtime.
在运行时配置具有命名空间的内核参数。

For the IPC namespace, the following sysctls are allowed:
对于 IPC 命名空间,允许以下 sysctl:

  • kernel.msgmax 内核.msgmax

  • kernel.msgmnb 内核.msgmnb

  • kernel.msgmni 内核.msgmni

  • kernel.sem 内核.sem

  • kernel.shmall 内核.shmall

  • kernel.shmmax 内核.shmmax

  • kernel.shmmni 内核.shmmni

  • kernel.shm_rmid_forced 内核.shm_rmid_forced

  • Sysctls beginning with fs.mqueue.*
    以 fs.mqueue.* 开头的 Sysctls

Note: if using the --ipc=host option, the above sysctls are not allowed.
注意:如果使用 --ipc=host 选项,则上述 sysctl 不允许使用。

For the network namespace, only sysctls beginning with net.* are allowed.
对于网络命名空间,只允许使用以 net.* 开头的 sysctl。

Note: if using the --network=host option, the above sysctls are not allowed.
注意:如果使用 --network=host 选项,则上述 sysctl 不允许使用。

--systemd=true | false | always

Run container in systemd mode. The default is true.
在 systemd 模式下运行容器。默认值为 true。

  • true enables systemd mode only when the command executed inside the container is systemd, /usr/sbin/init, /sbin/init or /usr/local/sbin/init.
    当容器内执行的命令为 systemd、/usr/sbin/init、/sbin/init 或 /usr/local/sbin/init 时,true 仅启用 systemd 模式。

  • false disables systemd mode.
    false 禁用 systemd 模式。

  • always enforces the systemd mode to be enabled.
    always 强制启用 systemd 模式。

Running the container in systemd mode causes the following changes:
在 systemd 模式下运行容器会导致以下更改:

  • Podman mounts tmpfs file systems on the following directories
    Podman 在以下目录上挂载 tmpfs 文件系统

    • /run

    • /run/lock

    • /tmp /临时

    • /sys/fs/cgroup/systemd (on a cgroup v1 system)
      /系统/文件系统/控制组/systemd(在 cgroup v1 系统上)

    • /var/lib/journal /变量/库/日志

  • Podman sets the default stop signal to SIGRTMIN+3.
    Podman 将默认停止信号设置为 SIGRTMIN+3。

  • Podman sets container_uuid environment variable in the container to the first 32 characters of the container ID.
    Podman 将 container_uuid 环境变量设置为容器中容器 ID 的前 32 个字符。

  • Podman does not mount virtual consoles (/dev/tty\d+) when running with --privileged.
    使用--privileged 运行时,Podman 不会挂载虚拟控制台(/dev/tty\d+)。

  • On cgroup v2, /sys/fs/cgroup is mounted writeable.
    在 cgroup v2 上,/sys/fs/cgroup 被挂载为可写。

This allows systemd to run in a confined container without any modifications.
这使得 systemd 可以在受限容器中运行而无需任何修改。

Note that on SELinux systems, systemd attempts to write to the cgroup file system. Containers writing to the cgroup file system are denied by default. The container_manage_cgroup boolean must be enabled for this to be allowed on an SELinux separated system.
请注意,在 SELinux 系统上,systemd 会尝试写入 cgroup 文件系统。默认情况下,容器被拒绝写入 cgroup 文件系统。在 SELinux 分离系统上,必须启用 container_manage_cgroup 布尔值才能允许这样做。

setsebool -P container_manage_cgroup true

--timeout=seconds --超时=秒 ¶

Maximum time a container is allowed to run before conmon sends it the kill signal. By default containers run until they exit or are stopped by podman stop.
容器在 conmon 发送终止信号之前允许运行的最长时间。默认情况下,容器运行直到退出或被 podman stop 停止。

--tls-verify

Require HTTPS and verify certificates when contacting registries (default: true). If explicitly set to true, TLS verification is used. If set to false, TLS verification is not used. If not specified, TLS verification is used unless the target registry is listed as an insecure registry in containers-registries.conf(5)
在联系注册表时需要 HTTPS 并验证证书(默认值为 true)。如果显式设置为 true,则使用 TLS 验证。如果设置为 false,则不使用 TLS 验证。如果未指定,则除非目标注册表在 containers-registries.conf(5) 中被列为不安全注册表,否则将使用 TLS 验证。

--tmpfs=fs

Create a tmpfs mount.
创建一个 tmpfs 挂载点。

Mount a temporary filesystem (tmpfs) mount into a container, for example:
将临时文件系统(tmpfs)挂载到容器中,例如:

$ podman create -d --tmpfs /tmp:rw,size=787448k,mode=1777 my_image

This command mounts a tmpfs at /tmp within the container. The supported mount options are the same as the Linux default mount flags. If no options are specified, the system uses the following options: rw,noexec,nosuid,nodev.
此命令在容器内的 /tmp 处挂载一个 tmpfs。支持的挂载选项与 Linux 默认的挂载标志相同。如果未指定任何选项,则系统将使用以下选项:rw,noexec,nosuid,nodev。

--tty, -t

Allocate a pseudo-TTY. The default is false.
分配一个伪终端。默认值为 false。

When set to true, Podman allocates a pseudo-tty and attach to the standard input of the container. This can be used, for example, to run a throwaway interactive shell.
当设置为 true 时,Podman 分配一个伪终端并附加到容器的标准输入。例如,可以用来运行一个临时的交互式 shell。

NOTE: The --tty flag prevents redirection of standard output. It combines STDOUT and STDERR, it can insert control characters, and it can hang pipes. This option is only used when run interactively in a terminal. When feeding input to Podman, use -i only, not -it.
注意:--tty 标志防止标准输出重定向。它结合了 STDOUT 和 STDERR,可以插入控制字符,并且可以挂起管道。此选项仅在终端交互式运行时使用。在向 Podman 提供输入时,仅使用 -i,而不是 -it。

--tz=timezone --tz=时区 ¶

Set timezone in container. This flag takes area-based timezones, GMT time, as well as local, which sets the timezone in the container to match the host machine. See /usr/share/zoneinfo/ for valid timezones. Remote connections use local containers.conf for defaults
在容器中设置时区。此标志接受基于区域的时区、GMT 时间,以及 local ,它将容器中的时区设置为与主机机器相匹配。请参阅 /usr/share/zoneinfo/ 以获取有效的时区。远程连接使用本地 containers.conf 作为默认值。

--uidmap=[flags]container_uid:from_uid[:amount]

Run the container in a new user namespace using the supplied UID mapping. This option conflicts with the --userns and --subuidname options. This option provides a way to map host UIDs to container UIDs. It can be passed several times to map different ranges.
使用提供的 UID 映射在新的用户命名空间中运行容器。此选项与 --userns 和 --subuidname 选项冲突。此选项提供了一种将主机 UID 映射到容器 UID 的方式。可以多次传递此选项以映射不同的范围。

The possible values of the optional flags are discussed further down on this page. The amount value is optional and assumed to be 1 if not given.
可选标志的可能值在本页下面进一步讨论。如果未提供,amount 值是可选的,并且假定为 1。

The from_uid value is based upon the user running the command, either rootful or rootless users.
from_uid 的值基于运行命令的用户,可以是 rootful 用户或 rootless 用户。

  • rootful user: [flags]container_uid:host_uid[:amount]
    rootful 用户:[标志]container_uid:host_uid[:数量]

  • rootless user: [flags]container_uid:intermediate_uid[:amount]
    rootless 用户:[标志]container_uid:intermediate_uid[:数量]

    Rootful mappings

When podman create is called by a privileged user, the option --uidmap works as a direct mapping between host UIDs and container UIDs.
当特权用户调用 podman create 时,选项 --uidmap 作为主机 UID 和容器 UID 之间的直接映射。

host UID -> container UID
主机 UID -> 容器 UID

The amount specifies the number of consecutive UIDs that is mapped. If for example amount is 4 the mapping looks like:
该数量指定了映射的连续 UID 数量。例如,如果数量为 4,则映射如下:

host UID 主机 UID

container UID 容器 UID

from_uid

container_uid

from_uid + 1

container_uid + 1 容器 UID + 1

from_uid + 2 来自 UID + 2

container_uid + 2 容器 UID + 2

from_uid + 3 从 from_uid + 3

container_uid + 3 从 container_uid + 3

Rootless mappings

When podman create is called by an unprivileged user (i.e. running rootless), the value from_uid is interpreted as an “intermediate UID”. In the rootless case, host UIDs are not mapped directly to container UIDs. Instead the mapping happens over two mapping steps:
当 podman create 被非特权用户调用时(即以 rootless 方式运行),from_uid 的值被解释为“中间 UID”。在 rootless 情况下,主机 UID 不直接映射到容器 UID。而是通过两个映射步骤进行映射。

host UID -> intermediate UID -> container UID
主机 UID -> 中间 UID -> 容器 UID

The --uidmap option only influences the second mapping step.
--uidmap 选项仅影响第二个映射步骤。

The first mapping step is derived by Podman from the contents of the file /etc/subuid and the UID of the user calling Podman.
第一个映射步骤由 Podman 从文件 /etc/subuid 的内容和调用 Podman 的用户的 UID 推导而来。

First mapping step: 第一映射步骤

host UID 主机 UID

intermediate UID 中间 UID

UID for Podman user Podman 用户的 UID

0

1st subordinate UID 第一个从属 UID

1

2nd subordinate UID 第二个从属 UID

2

3rd subordinate UID 第三个从属 UID

3

nth subordinate UID 第 n 个从属 UID

n

To be able to use intermediate UIDs greater than zero, the user needs to have subordinate UIDs configured in /etc/subuid. See subuid(5).
要能够使用大于零的中间 UID,用户需要在 /etc/subuid 中配置从属 UID。请参阅 subuid(5)。

The second mapping step is configured with --uidmap.
第二个映射步骤配置为--uidmap。

If for example amount is 5 the second mapping step looks like:
例如,如果数量为 5,则第二个映射步骤如下所示:

intermediate UID 中间 UID

container UID 容器 UID

from_uid

container_uid

from_uid + 1 来自 UID + 1

container_uid + 1 容器 UID + 1

from_uid + 2 来源用户 ID + 2

container_uid + 2 容器用户 ID + 2

from_uid + 3 来源用户 ID + 3

container_uid + 3 容器 UID + 3

from_uid + 4 来自 UID + 4

container_uid + 4 容器 UID + 4

When running as rootless, Podman uses all the ranges configured in the /etc/subuid file.
在以非 root 用户身份运行时,Podman 使用 /etc/subuid 文件中配置的所有范围。

The current user ID is mapped to UID=0 in the rootless user namespace. Every additional range is added sequentially afterward:
当前用户 ID 在非 root 用户命名空间中映射为 UID=0。每个额外的范围随后按顺序添加:

host

rootless user namespace 非 root 用户命名空间

length

$UID

0

1

1

$FIRST_RANGE_ID

$FIRST_RANGE_LENGTH

1+$FIRST_RANGE_LENGTH 1 + $FIRST_RANGE_LENGTH

$SECOND_RANGE_ID

$SECOND_RANGE_LENGTH

Referencing a host ID from the parent namespace

As a rootless user, the given host ID in --uidmap or --gidmap is mapped from the intermediate namespace generated by Podman. Sometimes it is desirable to refer directly at the host namespace. It is possible to manually do so, by running podman unshare cat /proc/self/gid_map, finding the desired host id at the second column of the output, and getting the corresponding intermediate id from the first column.
作为一个无根用户,在 Podman 生成的中间命名空间中,--uidmap 或 --gidmap 中给定的主机 ID 被映射。有时直接在主机命名空间中引用是可取的。可以通过手动运行 podman unshare cat /proc/self/gid_map 来实现,找到输出的第二列中的所需主机 ID,并从第一列获取相应的中间 ID。

Podman can perform all that by preceding the host id in the mapping with the @ symbol. For instance, by specifying --gidmap 100000:@2000:1, podman will look up the intermediate id corresponding to host id 2000 and it will map the found intermediate id to the container id 100000. The given host id must have been subordinated (otherwise it would not be mapped into the intermediate space in the first place).
Podman 可以通过在映射中的主机 ID 前加上 @ 符号来执行所有这些操作。例如,通过指定 --gidmap 100000:@2000:1 ,podman 将查找与主机 ID 2000 对应的中间 ID,并将找到的中间 ID 映射到容器 ID 100000 。给定的主机 ID 必须已经被下属(否则它不会首先被映射到中间空间)。

If the length is greater than one, for instance with --gidmap 100000:@2000:2, Podman will map host ids 2000 and 2001 to 100000 and 100001, respectively, regardless of how the intermediate mapping is defined.
如果长度大于一,例如使用 --gidmap 100000:@2000:2 ,Podman 将分别将主机 ID 20002001 映射到 100000100001 ,而不管中间映射如何定义。

Extending previous mappings

Some mapping modifications may be cumbersome. For instance, a user starts with a mapping such as --gidmap="0:0:65000", that needs to be changed such as the parent id 1000 is mapped to container id 100000 instead, leaving container id 1 unassigned. The corresponding --gidmap becomes --gidmap="0:0:1" --gidmap="2:2:65534" --gidmap="100000:1:1".
一些映射修改可能会很繁琐。例如,用户从一个类似 --gidmap="0:0:65000" 的映射开始,需要更改,如将父 ID 1000 映射到容器 ID 100000 ,而不是留下容器 ID 1 未分配。相应的 --gidmap 变为 --gidmap="0:0:1" --gidmap="2:2:65534" --gidmap="100000:1:1"

This notation can be simplified using the + flag, that takes care of breaking previous mappings removing any conflicting assignment with the given mapping. The flag is given before the container id as follows: --gidmap="0:0:65000" --gidmap="+100000:1:1"
这种表示法可以使用 + 标志简化,该标志负责打破先前的映射,删除任何与给定映射冲突的赋值。该标志在容器 ID 之前给出,如下所示: --gidmap="0:0:65000" --gidmap="+100000:1:1"

Flag

Example

Description

+

+100000:1:1

Extend the previous mapping
扩展前面的映射

This notation leads to gaps in the assignment, so it may be convenient to fill those gaps afterwards: --gidmap="0:0:65000" --gidmap="+100000:1:1" --gidmap="1:65001:1"
这种表示法会导致分配中出现间隙,因此在之后填补这些间隙可能会更方便: --gidmap="0:0:65000" --gidmap="+100000:1:1" --gidmap="1:65001:1"

One specific use case for this flag is in the context of rootless users. A rootless user may specify mappings with the + flag as in --gidmap="+100000:1:1". Podman will then “fill the gaps” starting from zero with all the remaining intermediate ids. This is convenient when a user wants to map a specific intermediate id to a container id, leaving the rest of subordinate ids to be mapped by Podman at will.
此标志的一个特定用例是在无根用户的情况下。 无根用户可以使用 + 标志指定映射,如 --gidmap="+100000:1:1" 。 Podman 然后将从零开始“填补间隙”,使用所有剩余的中间 ID。 当用户想要将特定的中间 ID 映射到容器 ID 时,这是方便的,剩下的从属 ID 将由 Podman 随意映射。

Passing only one of --uidmap or --gidmap

Usually, subordinated user and group ids are assigned simultaneously, and for any user the subordinated user ids match the subordinated group ids. For convenience, if only one of --uidmap or --gidmap is given, podman assumes the mapping refers to both UIDs and GIDs and applies the given mapping to both. If only one value of the two needs to be changed, the mappings should include the u or the g flags to specify that they only apply to UIDs or GIDs and should not be copied over.
通常,从属用户和组 ID 会同时分配,并且对于任何用户,从属用户 ID 与从属组 ID 匹配。 为方便起见,如果只提供 --uidmap 或 --gidmap 中的一个,podman 将假定映射同时指涉到 UID 和 GID,并将给定的映射应用于两者。 如果只需要更改两者中的一个值,则映射应包括 ug 标志,以指定它们仅适用于 UID 或 GID,并且不应被复制。

flag

Example

Description

u

u20000:2000:1

The mapping only applies to UIDs
该映射仅适用于 UID

g

g10000:1000:1

The mapping only applies to GIDs
该映射仅适用于 GID

For instance given the command
例如,给定命令

podman create --gidmap "0:0:1000" --gidmap "g2000:2000:1"

Since no --uidmap is given, the --gidmap is copied to --uidmap, giving a command equivalent to
由于未提供 --uidmap,--gidmap 被复制到 --uidmap,从而给出一个等效于的命令

podman create --gidmap "0:0:1000" --gidmap "2000:2000:1" --uidmap "0:0:1000"

The --gidmap "g2000:2000:1" used the g flag and therefore it was not copied to --uidmap.
--gidmap "g2000:2000:1" 使用了 g 标志,因此它没有被复制到 --uidmap。

Rootless mapping of additional host GIDs

A rootless user may desire to map a specific host group that has already been subordinated within /etc/subgid without specifying the rest of the mapping.
一个无根用户可能希望映射一个已经在 /etc/subgid 中被从属的特定主机组,而不指定其余的映射。

This can be done with --gidmap “+gcontainer_gid:@host_gid
这可以通过 --gidmap “+gcontainer_gid:@host_gid” 完成

Where: 其中:

  • The host GID is given through the @ symbol
    主机 GID 通过 @ 符号给出

  • The mapping of this GID is not copied over to --usermap thanks to the g flag.
    此 GID 的映射未复制到 --usermap,这要归功于 g 标志。

  • The rest of the container IDs will be mapped starting from 0 to n, with all the remaining subordinated GIDs, thanks to the + flag.
    其余的容器 ID 将从 0 到 n 进行映射,所有剩余的从属 GID 也将归功于 + 标志。

For instance, if a user belongs to the group 2000 and that group is subordinated to that user (with usermod --add-subgids 2000-2000 $USER), the user can map the group into the container with: --gidmap=+g100000:@2000.
例如,如果用户属于组 2000 ,并且该组从属于该用户(使用 usermod --add-subgids 2000-2000 $USER ),则用户可以使用以下方式将组映射到容器中:--gidmap=+g100000:@2000。

If this mapping is combined with the option, --group-add=keep-groups, the process in the container will belong to group 100000, and files belonging to group 2000 in the host will appear as being owned by group 100000 inside the container.
如果此映射与选项 --group-add=keep-groups 结合使用,则容器中的进程将属于组 100000 ,主机中属于组 2000 的文件将显示为容器内部组 100000 拥有。

podman run --group-add=keep-groups --gidmap="+g100000:@2000" ...

No subordinate UIDs

Even if a user does not have any subordinate UIDs in /etc/subuid, --uidmap can be used to map the normal UID of the user to a container UID by running podman create --uidmap $container_uid:0:1 --user $container_uid ....
即使用户在 /etc/subuid 中没有任何从属的 UID,也可以通过运行 podman create --uidmap $container_uid:0:1 --user $container_uid ... 使用 --uidmap 将用户的普通 UID 映射到容器 UID。

Pods

The --uidmap option cannot be called in conjunction with the --pod option as a uidmap cannot be set on the container level when in a pod.
当在 pod 中时,无法在容器级别设置 uidmap,因此无法在 --pod 选项与 --uidmap 选项一起调用。

--ulimit=option --ulimit=选项 ¶

Ulimit options. Sets the ulimits values inside of the container.
Ulimit 选项。设置容器内的 ulimits 值。

--ulimit with a soft and hard limit in the format =[:]. For example:
--ulimit 以格式 =[:soft_limit:hard_limit] 的形式设置软限制和硬限制。例如:

$ podman run --ulimit nofile=1024:1024 --rm ubi9 ulimit -n 1024

Set -1 for the soft or hard limit to set the limit to the maximum limit of the current process. In rootful mode this is often unlimited.
将软限制或硬限制设置为-1,以将限制设置为当前进程的最大限制。在 rootful 模式下,这通常是无限制的。

Use host to copy the current configuration from the host.
使用 host 从主机复制当前配置。

Don’t use nproc with the ulimit flag as Linux uses nproc to set the maximum number of processes available to a user, not to a container.
不要使用 nproc 与 ulimit 标志,因为 Linux 使用 nproc 来设置用户可用的最大进程数,而不是容器。

Use the --pids-limit option to modify the cgroup control to limit the number of processes within a container.
使用 --pids-limit 选项来修改 cgroup 控制以限制容器内的进程数量。

--umask=umask --umask=umask

Set the umask inside the container. Defaults to 0022. Remote connections use local containers.conf for defaults
在容器内设置 umask。默认为 0022 。远程连接使用本地 containers.conf 的默认值

--unsetenv=env --unsetenv=env

Unset default environment variables for the container. Default environment variables include variables provided natively by Podman, environment variables configured by the image, and environment variables from containers.conf.
取消容器的默认环境变量。默认环境变量包括 Podman 本身提供的变量、镜像配置的环境变量以及 containers.conf 中的环境变量。

--unsetenv-all --unsetenv-all

Unset all default environment variables for the container. Default environment variables include variables provided natively by Podman, environment variables configured by the image, and environment variables from containers.conf.
取消容器的所有默认环境变量。默认环境变量包括 Podman 本地提供的变量,镜像配置的环境变量以及 containers.conf 中的环境变量。

--user, -u=user[:group]

Sets the username or UID used and, optionally, the groupname or GID for the specified command. Both user and group may be symbolic or numeric.
设置指定命令使用的用户名或 UID,可选地,还可以设置组名或 GID。用户和组都可以是符号或数字。

Without this argument, the command runs as the user specified in the container image. Unless overridden by a USER command in the Containerfile or by a value passed to this option, this user generally defaults to root.
没有此参数,命令将作为容器镜像中指定的用户运行。除非在 Containerfile 中被 USER 命令覆盖或者通过传递给此选项的值覆盖,否则该用户通常默认为 root。

When a user namespace is not in use, the UID and GID used within the container and on the host match. When user namespaces are in use, however, the UID and GID in the container may correspond to another UID and GID on the host. In rootless containers, for example, a user namespace is always used, and root in the container by default corresponds to the UID and GID of the user invoking Podman.
当未使用用户命名空间时,容器内部和主机上使用的 UID 和 GID 相匹配。然而,当使用用户命名空间时,容器中的 UID 和 GID 可能对应于主机上的另一个 UID 和 GID。例如,在无根容器中,总是使用用户命名空间,默认情况下容器中的 root 对应于调用 Podman 的用户的 UID 和 GID。

--userns=mode --userns=mode

Set the user namespace mode for the container.
为容器设置用户命名空间模式。

If --userns is not set, the default value is determined as follows.
如果未设置 --userns ,则默认值将如下确定。

  • If --pod is set, --userns is ignored and the user namespace of the pod is used.
    如果设置了 --pod ,则 --userns 将被忽略,且使用 Pod 的用户命名空间。

  • If the environment variable PODMAN_USERNS is set its value is used.
    如果环境变量 PODMAN_USERNS 已设置,则使用其值。

  • If userns is specified in containers.conf this value is used.
    如果在 containers.conf 中指定了 userns ,则使用该值。

  • Otherwise, --userns=host is assumed.
    否则,假定为 --userns=host

--userns="" (i.e., an empty string) is an alias for --userns=host.
--userns="" (即空字符串)是 --userns=host 的别名。

This option is incompatible with --gidmap, --uidmap, --subuidname and --subgidname.
此选项与--gidmap、--uidmap、--subuidname 和--subgidname 不兼容。

Rootless user --userns=Key mappings:
无根用户--userns=Key 映射:

Key

Host User 主机用户

Container User 容器用户

auto

$UID

nil (Host User UID is not mapped into container.)
nil(主机用户 UID 未映射到容器中。)

host

$UID

0 (Default User account mapped to root user in container.)
0(默认用户帐户映射到容器中的 root 用户。)

keep-id

$UID

$UID (Map user account to same UID within container.)
$UID(将用户帐户映射到容器内相同的 UID。)

keep-id:uid=200,gid=210

$UID

200:210 (Map user account to specified UID, GID value within container.)
200:210(将用户帐户映射到容器内指定的 UID、GID 值。)

nomap

$UID

nil (Host User UID is not mapped into container.)
nil(主机用户 UID 未映射到容器。)

Valid mode values are: 有效的模式值为:

auto[:OPTIONS,…]: automatically create a unique user namespace.
auto[:OPTIONS,…]:自动创建唯一的用户命名空间。

  • rootful mode: The --userns=auto flag requires that the user name containers be specified in the /etc/subuid and /etc/subgid files, with an unused range of subordinate user IDs that Podman containers are allowed to allocate.
    rootful mode--userns=auto 标志要求在 /etc/subuid 和 /etc/subgid 文件中指定容器的用户名,使用未使用的次要用户 ID 范围,Podman 容器允许分配。

     Example: `containers:2147483647:2147483648`.
    
  • rootless mode: The users range from the /etc/subuid and /etc/subgid files will be used. Note running a single container without using --userns=auto will use the entire range of UIDs and not allow further subdividing. See subuid(5).
    rootless mode :用户范围从 /etc/subuid 和 /etc/subgid 文件中获取。请注意,如果不使用 --userns=auto 运行单个容器,则将使用整个 UID 范围,不允许进一步细分。请参阅 subuid(5)。

Podman allocates unique ranges of UIDs and GIDs from the containers subordinate user IDs. The size of the ranges is based on the number of UIDs required in the image. The number of UIDs and GIDs can be overridden with the size option.
Podman 从 containers 从属用户 ID 中分配唯一的 UID 和 GID 范围。范围的大小取决于镜像中所需的 UID 数量。可以使用 size 选项覆盖 UID 和 GID 的数量。

The option --userns=keep-id uses all the subuids and subgids of the user. The option --userns=nomap uses all the subuids and subgids of the user except the user’s own ID. Using --userns=auto when starting new containers does not work as long as any containers exist that were started with --userns=keep-id or --userns=nomap.
选项 --userns=keep-id 使用用户的所有子 UID 和子 GID。选项 --userns=nomap 使用用户的所有子 UID 和子 GID,但不包括用户自己的 ID。只要存在使用 --userns=keep-id--userns=nomap 启动的容器,使用 --userns=auto 启动新容器将无法正常工作。

Valid auto options: 有效的 auto 选项:

  • gidmapping=CONTAINER_GID:HOST_GID:SIZE: to force a GID mapping to be present in the user namespace.
    gidmapping=CONTAINER_GID:HOST_GID:SIZE: 用于强制在用户命名空间中存在 GID 映射。

  • size=SIZE: to specify an explicit size for the automatic user namespace. e.g. --userns=auto:size=8192. If size is not specified, auto estimates a size for the user namespace.
    size=SIZE: 用于为自动用户命名空间指定显式大小。例如 --userns=auto:size=8192 。如果未指定 sizeauto 会为用户命名空间估算一个大小。

  • uidmapping=CONTAINER_UID:HOST_UID:SIZE: to force a UID mapping to be present in the user namespace.
    uidmapping=CONTAINER_UID:HOST_UID:SIZE: 强制在用户命名空间中存在 UID 映射。

The host UID and GID in gidmapping and uidmapping can optionally be prefixed with the @ symbol. In this case, podman will look up the intermediate ID corresponding to host ID and it will map the found intermediate ID to the container id. For details see --uidmap.
gidmapping 和 uidmapping 中的主机 UID 和 GID 可以选择性地以 @ 符号为前缀。在这种情况下,podman 将查找与主机 ID 对应的中间 ID,并将找到的中间 ID 映射到容器 ID。有关详细信息,请参阅 --uidmap。

container:id: join the user namespace of the specified container.
container:id: 加入指定容器的用户命名空间。

host or “” (empty string): run in the user namespace of the caller. The processes running in the container have the same privileges on the host as any other process launched by the calling user.
主机或“”(空字符串):在调用者的用户命名空间中运行。在容器中运行的进程在主机上具有与调用用户启动的任何其他进程相同的特权。

keep-id: creates a user namespace where the current user’s UID:GID are mapped to the same values in the container. For containers created by root, the current mapping is created into a new user namespace.
keep-id:创建一个用户命名空间,其中当前用户的 UID:GID 被映射到容器中的相同值。对于由 root 创建的容器,当前映射被创建到一个新的用户命名空间中。

Valid keep-id options: 有效的 keep-id 选项:

  • uid=UID: override the UID inside the container that is used to map the current user to.
    uid=UID: 覆盖容器内用于映射当前用户的 UID。

  • gid=GID: override the GID inside the container that is used to map the current user to.
    gid=GID: 覆盖容器内用于映射当前用户的 GID。

nomap: creates a user namespace where the current rootless user’s UID:GID are not mapped into the container. This option is not allowed for containers created by the root user.
nomap: 创建一个用户命名空间,其中当前无根用户的 UID:GID 不映射到容器中。此选项不允许由 root 用户创建的容器使用。

ns:namespace: run the container in the given existing user namespace.
ns:namespace: 在给定的现有用户命名空间中运行容器。

--uts=mode

Set the UTS namespace mode for the container. The following values are supported:
为容器设置 UTS 命名空间模式。支持以下值:

  • host: use the host’s UTS namespace inside the container.
    主机:在容器内使用主机的 UTS 命名空间。

  • private: create a new namespace for the container (default).
    私有:为容器创建一个新的命名空间(默认)。

  • ns:[path]: run the container in the given existing UTS namespace.
    ns:[路径]:在给定的现有 UTS 命名空间中运行容器。

  • container:[container]: join the UTS namespace of the specified container.
    container:[container]: 加入指定容器的 UTS 命名空间。

--variant=VARIANT

Use VARIANT instead of the default architecture variant of the container image. Some images can use multiple variants of the arm architectures, such as arm/v5 and arm/v7.
使用 VARIANT 替代容器镜像的默认架构变体。某些镜像可以使用 arm 架构的多个变体,例如 arm/v5 和 arm/v7。

--volume, -v=[[SOURCE-VOLUME|HOST-DIR:]CONTAINER-DIR[:OPTIONS]]
--volume, -v=[[源卷|主机目录:]容器目录[:选项]] ¶

Create a bind mount. If -v /HOST-DIR:/CONTAINER-DIR is specified, Podman bind mounts /HOST-DIR from the host into /CONTAINER-DIR in the Podman container. Similarly, -v SOURCE-VOLUME:/CONTAINER-DIR mounts the named volume from the host into the container. If no such named volume exists, Podman creates one. If no source is given, the volume is created as an anonymously named volume with a randomly generated name, and is removed when the container is removed via the --rm flag or the podman rm --volumes command.
创建一个绑定挂载。如果指定了 -v /HOST-DIR:/CONTAINER-DIR ,Podman 将主机中的 /HOST-DIR 绑定挂载到 Podman 容器中的 /CONTAINER-DIR 。类似地, -v SOURCE-VOLUME:/CONTAINER-DIR 将命名卷从主机绑定到容器中。如果没有这样的命名卷存在,Podman 将创建一个。如果没有给出源,则该卷将作为一个具有随机生成名称的匿名命名卷创建,并在通过 --rm 标志或 podman rm --volumes 命令删除容器时被删除。

(Note when using the remote client, including Mac and Windows (excluding WSL2) machines, the volumes are mounted from the remote server, not necessarily the client machine.)
(注意,当使用远程客户端时,包括 Mac 和 Windows(不包括 WSL2)机器时,卷是从远程服务器挂载的,而不一定是客户端机器。)

The OPTIONS is a comma-separated list and can be one or more of:
OPTIONS 是一个逗号分隔的列表,可以是一个或多个:

  • rw|ro

  • z|Z

  • [O]

  • [U]

  • [no]copy

  • [no]dev [不]开发

  • [no]exec [不]执行

  • [no]suid [不]SUID

  • [r]bind [r]绑定

  • [r]shared|[r]slave|[r]private[r]unbindable [1]
    [r]共享|[r]从属|[r]私有[r]不可解绑 [1]

  • idmap[=options] id 映射[=选项]

The CONTAINER-DIR must be an absolute path such as /src/docs. The volume is mounted into the container at this directory.
" CONTAINER-DIR " 必须是绝对路径,例如 " /src/docs "。卷被挂载到容器中的这个目录。

If a volume source is specified, it must be a path on the host or the name of a named volume. Host paths are allowed to be absolute or relative; relative paths are resolved relative to the directory Podman is run in. If the source does not exist, Podman returns an error. Users must pre-create the source files or directories.
如果指定了卷源,则必须是主机上的路径或命名卷的名称。主机路径可以是绝对或相对的;相对路径相对于 Podman 运行的目录解析。如果源不存在,Podman 将返回错误。用户必须预先创建源文件或目录。

Any source that does not begin with a . or / is treated as the name of a named volume. If a volume with that name does not exist, it is created. Volumes created with names are not anonymous, and they are not removed by the --rm option and the podman rm --volumes command.
任何不以 " . " 或 " / " 开头的源都被视为命名卷的名称。如果不存在具有该名称的卷,则会创建它。使用名称创建的卷不是匿名的,并且不会被 " --rm " 选项和 " podman rm --volumes " 命令移除。

Specify multiple -v options to mount one or more volumes into a container.
指定多个 -v 选项将一个或多个卷挂载到容器中。

Write Protected Volume Mounts

Add :ro or :rw option to mount a volume in read-only or read-write mode, respectively. By default, the volumes are mounted read-write. See examples.
添加 :ro 或 :rw 选项以分别以只读或读写模式挂载卷,默认情况下,卷以读写模式挂载。请参阅示例。

Chowning Volume Mounts

By default, Podman does not change the owner and group of source volume directories mounted into containers. If a container is created in a new user namespace, the UID and GID in the container may correspond to another UID and GID on the host.
默认情况下,Podman 不会更改挂载到容器中的源卷目录的所有者和组。如果在新的用户命名空间中创建容器,则容器中的 UID 和 GID 可能对应主机上的另一个 UID 和 GID。

The :U suffix tells Podman to use the correct host UID and GID based on the UID and GID within the container, to change recursively the owner and group of the source volume. Chowning walks the file system under the volume and changes the UID/GID on each file. If the volume has thousands of inodes, this process takes a long time, delaying the start of the container.
:U 后缀告诉 Podman 根据容器内的 UID 和 GID 使用正确的主机 UID 和 GID,递归地更改源卷的所有者和组。Chowning 遍历卷下的文件系统,并更改每个文件的 UID/GID。如果卷有数千个 inode,则此过程需要很长时间,延迟容器的启动。

Warning use with caution since this modifies the host filesystem.
警告谨慎使用,因为这会修改主机文件系统。

Labeling Volume Mounts

Labeling systems like SELinux require that proper labels are placed on volume content mounted into a container. Without a label, the security system might prevent the processes running inside the container from using the content. By default, Podman does not change the labels set by the OS.
类似 SELinux 的标签系统要求在挂载到容器中的卷内容上放置适当的标签。如果没有标签,安全系统可能会阻止容器内运行的进程使用内容。默认情况下,Podman 不会更改操作系统设置的标签。

To change a label in the container context, add either of two suffixes :z or :Z to the volume mount. These suffixes tell Podman to relabel file objects on the shared volumes. The z option tells Podman that two or more containers share the volume content. As a result, Podman labels the content with a shared content label. Shared volume labels allow all containers to read/write content. The Z option tells Podman to label the content with a private unshared label Only the current container can use a private volume. Relabeling walks the file system under the volume and changes the label on each file, if the volume has thousands of inodes, this process takes a long time, delaying the start of the container. If the volume was previously relabeled with the z option, Podman is optimized to not relabel a second time. If files are moved into the volume, then the labels can be manually change with the chcon -Rt container_file_t PATH command.
要在容器上下文中更改标签,请在卷挂载中添加两个后缀之一::z 或 :Z。这些后缀告诉 Podman 重新标记共享卷上的文件对象。z 选项告诉 Podman 两个或更多容器共享卷内容。因此,Podman 使用共享内容标签标记内容。共享卷标签允许所有容器读取/写入内容。Z 选项告诉 Podman 使用私有未共享标签标记内容。只有当前容器可以使用私有卷。重新标记会遍历卷下的文件系统,并更改每个文件的标签,如果卷有数千个 inode,则此过程需要很长时间,延迟容器的启动。如果卷之前使用 z 选项重新标记过,则 Podman 会优化以避免二次重新标记。如果文件移动到卷中,则可以使用 chcon -Rt container_file_t PATH 命令手动更改标签。

Note: Do not relabel system files and directories. Relabeling system content might cause other confined services on the machine to fail. For these types of containers we recommend disabling SELinux separation. The option --security-opt label=disable disables SELinux separation for the container. For example if a user wanted to volume mount their entire home directory into a container, they need to disable SELinux separation.
注意:不要重新标记系统文件和目录。重新标记系统内容可能会导致机器上其他受限服务失败。对于这些类型的容器,我们建议禁用 SELinux 分离。选项 --security-opt label=disable 会为容器禁用 SELinux 分离。例如,如果用户想要将他们整个家目录挂载到容器中,他们需要禁用 SELinux 分离。

$ podman create --security-opt label=disable -v $HOME:/home/user fedora touch /home/user/file

Overlay Volume Mounts

The :O flag tells Podman to mount the directory from the host as a temporary storage using the overlay file system. The container processes can modify content within the mountpoint which is stored in the container storage in a separate directory. In overlay terms, the source directory is the lower, and the container storage directory is the upper. Modifications to the mount point are destroyed when the container finishes executing, similar to a tmpfs mount point being unmounted.
:O 标志告诉 Podman 将主机上的目录作为临时存储挂载,使用 overlay file system 。容器进程可以修改挂载点内的内容,这些内容存储在容器存储中的一个单独目录中。在叠加术语中,源目录是下层,容器存储目录是上层。对挂载点的修改在容器执行完成后被销毁,类似于 tmpfs 挂载点被卸载时的情况。

For advanced users, the overlay option also supports custom non-volatile upperdir and workdir for the overlay mount. Custom upperdir and workdir can be fully managed by the users themselves, and Podman does not remove it on lifecycle completion. Example :O,upperdir=/some/upper,workdir=/some/work
对于高级用户,overlay 选项还支持自定义非易失性 upperdir 和 workdir 用于叠加挂载。自定义的 upperdir 和 workdir 可完全由用户自行管理,Podman 在生命周期完成时不会删除它。示例:O,upperdir=/some/upper,workdir=/some/work

Subsequent executions of the container sees the original source directory content, any changes from previous container executions no longer exist.
容器的后续执行会看到原始源目录内容,之前容器执行中的任何更改都不再存在。

One use case of the overlay mount is sharing the package cache from the host into the container to allow speeding up builds.
叠加挂载的一个用例是将主机中的软件包缓存共享到容器中,以加快构建速度。

Note: The O flag conflicts with other options listed above.
注意: O 标志与上面列出的其他选项存在冲突。

Content mounted into the container is labeled with the private label. On SELinux systems, labels in the source directory must be readable by the container label. Usually containers can read/execute container_share_t and can read/write container_file_t. If unable to change the labels on a source volume, SELinux container separation must be disabled for the container to work.
安装到容器中的内容带有私有标签。在 SELinux 系统上,源目录中的标签必须对容器标签可读。通常容器可以读取/执行 container_share_t 并且可以读取/写入 container_file_t 。如果无法更改源卷上的标签,则必须为容器禁用 SELinux 容器隔离才能正常工作。

Do not modify the source directory mounted into the container with an overlay mount, it can cause unexpected failures. Only modify the directory after the container finishes running.
不要使用覆盖挂载修改安装到容器中的源目录,这可能导致意外故障。只能在容器运行完成后修改目录。

Mounts propagation

By default, bind-mounted volumes are private. That means any mounts done inside the container are not visible on the host and vice versa. One can change this behavior by specifying a volume mount propagation property. When a volume is shared, mounts done under that volume inside the container are visible on host and vice versa. Making a volume slave[1] enables only one-way mount propagation: mounts done on the host under that volume are visible inside the container but not the other way around.
默认情况下,绑定挂载的卷是 private 的。这意味着容器内部进行的任何挂载对主机都不可见,反之亦然。可以通过指定卷挂载传播属性来更改此行为。当一个卷是 shared 时,在容器内部该卷下进行的挂载对主机可见,反之亦然。将卷设置为 [1] 会启用单向挂载传播:在主机上该卷下进行的挂载在容器内部可见,但反之则不行。

To control mount propagation property of a volume one can use the [r]shared, [r]slave, [r]private or the [r]unbindable propagation flag. Propagation property can be specified only for bind mounted volumes and not for internal volumes or named volumes. For mount propagation to work the source mount point (the mount point where source dir is mounted on) has to have the right propagation properties. For shared volumes, the source mount point has to be shared. And for slave volumes, the source mount point has to be either shared or slave. [1]
要控制卷的挂载传播属性,可以使用[r]shared、[r]slave、[r]private 或[r]unbindable 传播标志。传播属性只能针对绑定挂载的卷进行指定,而不能针对内部卷或命名卷进行指定。要使挂载传播生效,源挂载点(源目录挂载的挂载点)必须具有正确的传播属性。对于共享卷,源挂载点必须是共享的。对于从属卷,源挂载点必须是共享的或从属的。 [1]

To recursively mount a volume and all of its submounts into a container, use the rbind option. By default the bind option is used, and submounts of the source directory is not mounted into the container.
要递归地将卷及其所有子挂载点挂载到容器中,请使用 rbind 选项。默认情况下使用 bind 选项,并且源目录的子挂载点不会挂载到容器中。

Mounting the volume with a copy option tells podman to copy content from the underlying destination directory onto newly created internal volumes. The copy only happens on the initial creation of the volume. Content is not copied up when the volume is subsequently used on different containers. The copy option is ignored on bind mounts and has no effect.
使用复制选项挂载卷告诉 podman 从底层目标目录复制内容到新创建的内部卷。复制仅在卷的初始创建时发生。在不同容器上后续使用卷时,内容不会被复制。复制选项在绑定挂载上被忽略且无效果。

Mounting volumes with the nosuid options means that SUID executables on the volume can not be used by applications to change their privilege. By default volumes are mounted with nosuid.
使用 nosuid 选项挂载卷意味着卷上的 SUID 可执行文件不能被应用程序用来更改它们的特权。默认情况下,卷是使用 nosuid 挂载的。

Mounting the volume with the noexec option means that no executables on the volume can be executed within the container.
使用 noexec 选项挂载卷意味着容器内无法执行卷上的可执行文件。

Mounting the volume with the nodev option means that no devices on the volume can be used by processes within the container. By default volumes are mounted with nodev.
使用 nodev 选项挂载卷意味着卷上的设备不能被容器内的进程使用。默认情况下,卷是使用 nodev 挂载的。

If the HOST-DIR is a mount point, then dev, suid, and exec options are ignored by the kernel.
如果 HOST-DIR 是一个挂载点,则内核会忽略 dev、suid 和 exec 选项。

Use df HOST-DIR to figure out the source mount, then use findmnt -o TARGET,PROPAGATION source-mount-dir to figure out propagation properties of source mount. If findmnt(1) utility is not available, then one can look at the mount entry for the source mount point in /proc/self/mountinfo. Look at the “optional fields” and see if any propagation properties are specified. In there, shared:N means the mount is shared, master:N means mount is slave, and if nothing is there, the mount is private. [1]
使用 df HOST-DIR 来查找源挂载点,然后使用 findmnt -o TARGET,PROPAGATION source-mount-dir 来查找源挂载点的传播属性。如果 findmnt(1) 实用程序不可用,则可以查看 /proc/self/mountinfo 中源挂载点的挂载条目。查看“可选字段”,看看是否指定了任何传播属性。在那里,shared:N 表示挂载是共享的,master:N 表示挂载是从属的,如果没有任何内容,则挂载是私有的。 [1]

To change propagation properties of a mount point, use mount(8) command. For example, if one wants to bind mount source directory /foo, one can do mount --bind /foo /foo and mount --make-private --make-shared /foo. This converts /foo into a shared mount point. Alternatively, one can directly change propagation properties of source mount. Say / is source mount for /foo, then use mount --make-shared / to convert / into a shared mount.
要更改挂载点的传播属性,请使用 mount(8) 命令。例如,如果要绑定挂载源目录 /foo,则可以执行 mount --bind /foo /foo 和 mount --make-private --make-shared /foo。这将把 /foo 转换为共享挂载点。或者,可以直接更改源挂载点的传播属性。假设 / 是 /foo 的源挂载点,则使用 mount --make-shared / 来将 / 转换为共享挂载点。

Note: if the user only has access rights via a group, accessing the volume from inside a rootless container fails.
注意:如果用户仅通过组具有访问权限,则从无根容器内访问卷会失败。

Idmapped mount

If idmap is specified, create an idmapped mount to the target user namespace in the container. The idmap option supports a custom mapping that can be different than the user namespace used by the container. The mapping can be specified after the idmap option like: idmap=uids=0-1-10#10-11-10;gids=0-100-10. For each triplet, the first value is the start of the backing file system IDs that are mapped to the second value on the host. The length of this mapping is given in the third value. Multiple ranges are separated with #.
如果指定了 idmap ,则在容器中为目标用户命名空间创建一个 idmapped 挂载点。idmap 选项支持自定义映射,可以与容器使用的用户命名空间不同。映射可以在 idmap 选项之后指定,如: idmap=uids=0-1-10#10-11-10;gids=0-100-10 。对于每个三元组,第一个值是映射到主机上第二个值的后备文件系统 ID 的起始值。此映射的长度在第三个值中给出。多个范围用 # 分隔。

Use the --group-add keep-groups option to pass the user’s supplementary group access into the container.
使用 --group-add keep-groups 选项将用户的附加组访问权限传递到容器中。

--volumes-from=CONTAINER[:OPTIONS]

Mount volumes from the specified container(s). Used to share volumes between containers. The options is a comma-separated list with the following available elements:
从指定容器挂载卷。用于在容器之间共享卷。选项是一个逗号分隔的列表,包含以下可用元素:

  • rw|ro 读写|只读

  • z

Mounts already mounted volumes from a source container onto another container. CONTAINER may be a name or ID. To share a volume, use the --volumes-from option when running the target container. Volumes can be shared even if the source container is not running.
将已挂载卷从源容器挂载到另一个容器。CONTAINER 可以是名称或 ID。要共享卷,请在运行目标容器时使用 --volumes-from 选项。即使源容器未运行,也可以共享卷。

By default, Podman mounts the volumes in the same mode (read-write or read-only) as it is mounted in the source container. This can be changed by adding a ro or rw option.
默认情况下,Podman 以与源容器中挂载的模式(读写或只读)相同的模式挂载卷。可以通过添加 rorw 选项来更改这一点。

Labeling systems like SELinux require that proper labels are placed on volume content mounted into a container. Without a label, the security system might prevent the processes running inside the container from using the content. By default, Podman does not change the labels set by the OS.
类似 SELinux 的标签系统要求在挂载到容器中的卷内容上放置适当的标签。如果没有标签,安全系统可能会阻止容器内运行的进程使用内容。默认情况下,Podman 不会更改操作系统设置的标签。

To change a label in the container context, add z to the volume mount. This suffix tells Podman to relabel file objects on the shared volumes. The z option tells Podman that two entities share the volume content. As a result, Podman labels the content with a shared content label. Shared volume labels allow all containers to read/write content.
要在容器上下文中更改标签,请在卷挂载中添加 z 。此后缀告诉 Podman 重新标记共享卷上的文件对象。 z 选项告诉 Podman 两个实体共享卷内容。因此,Podman 使用共享内容标签标记内容。共享卷标签允许所有容器读写内容。

If the location of the volume from the source container overlaps with data residing on a target container, then the volume hides that data on the target.
如果源容器中卷的位置与目标容器上的数据重叠,则该卷将隐藏目标上的数据。

--workdir, -w=dir

Working directory inside the container.
容器内的工作目录。

The default working directory for running binaries within a container is the root directory (/). The image developer can set a different default with the WORKDIR instruction. The operator can override the working directory by using the -w option.
在容器内运行二进制文件的默认工作目录是根目录(/)。镜像开发者可以使用 WORKDIR 指令设置不同的默认工作目录。操作员可以使用 -w 选项覆盖工作目录。

EXAMPLES 示例

Create a container using a local image:
使用本地镜像创建容器:

$ podman create alpine ls

Create a container using a local image and annotate it:
使用本地镜像创建容器并对其进行注释:

$ podman create --annotation HELLO=WORLD alpine ls

Create a container using a local image, allocating a pseudo-TTY, keeping stdin open and name it myctr:
使用本地镜像创建容器,分配伪终端,保持标准输入打开,并将其命名为 myctr:

  podman create -t -i --name myctr alpine ls

Running a container in a new user namespace requires a mapping of the UIDs and GIDs from the host:
在新用户命名空间中运行容器需要将主机的 UID 和 GID 进行映射:

$ podman create --uidmap 0:30000:7000 --gidmap 0:30000:7000 fedora echo hello

Setting automatic user-namespace separated containers:
设置自动用户命名空间分离的容器:

# podman create --userns=auto:size=65536 ubi8-init

Configure the timezone in a container:
在容器中配置时区:

$ podman create --tz=local alpine date
$ podman create --tz=Asia/Shanghai alpine date
$ podman create --tz=US/Eastern alpine date

Ensure the first container (container1) is running before the second container (container2) is started:
确保第一个容器(container1)在第二个容器(container2)启动之前正在运行:

$ podman create --name container1 -t -i fedora bash
$ podman create --name container2 --requires container1 -t -i fedora bash
$ podman start --attach container2

Create a container which requires multiple containers:
创建一个需要多个容器的容器:

$ podman create --name container1 -t -i fedora bash
$ podman create --name container2 -t -i fedora bash
$ podman create --name container3 --requires container1,container2 -t -i fedora bash
$ podman start --attach container3

Expose shared libraries inside of container as read-only using a glob:
在容器内将共享库作为只读使用通配符暴露出来

$ podman create --mount type=glob,src=/usr/lib64/libnvidia\*,ro -i -t fedora /bin/bash

Create a container allowing supplemental groups to have access to the volume:
创建一个允许附加组访问卷的容器

$ podman create -v /var/lib/design:/var/lib/design --group-add keep-groups ubi8

Configure execution domain for containers using the personality option:
使用 personality 选项为容器配置执行域

$ podman create --name container1 --personality=LINUX32 fedora bash

Create a container with external rootfs mounted as an overlay:
使用外部 rootfs 挂载作为叠加层创建容器:

$ podman create --name container1 --rootfs /path/to/rootfs:O bash

Create a container connected to two networks (called net1 and net2) with a static ip:
创建连接到两个网络(称为 net1 和 net2)并具有静态 IP 的容器:

$ podman create --network net1:ip=10.89.1.5 --network net2:ip=10.89.10.10 alpine ip addr

Rootless Containers 无根容器 ¶

Podman runs as a non-root user on most systems. This feature requires that a new enough version of shadow-utils be installed. The shadow-utils package must include the newuidmap and newgidmap executables.
Podman 在大多数系统上以非 root 用户身份运行。此功能要求安装足够新版本的 shadow-utils。shadow-utils 软件包必须包含 newuidmap 和 newgidmap 可执行文件。

In order for users to run rootless, there must be an entry for their username in /etc/subuid and /etc/subgid which lists the UIDs for their user namespace.
为了让用户以非 root 用户身份运行,必须在 /etc/subuid 和 /etc/subgid 中为他们的用户名添加条目,列出其用户命名空间的 UID。

Rootless Podman works better if the fuse-overlayfs and slirp4netns packages are installed. The fuse-overlayfs package provides a userspace overlay storage driver, otherwise users need to use the vfs storage driver, which can be disk space expensive and less performant than other drivers.
如果安装了 fuse-overlayfs 和 slirp4netns 软件包,Rootless Podman 的工作效果会更好。fuse-overlayfs 软件包提供了一个用户空间的覆盖存储驱动程序,否则用户需要使用 vfs 存储驱动程序,这可能会占用磁盘空间并且性能不如其他驱动程序。

To enable VPN on the container, slirp4netns or pasta needs to be specified; without either, containers need to be run with the --network=host flag.
要在容器上启用 VPN,需要指定 slirp4netns 或 pasta;如果没有其中任何一个,容器需要使用 --network=host 标志运行。

ENVIRONMENT 环境

Environment variables within containers can be set using multiple different options: This section describes the precedence.
容器内的环境变量可以使用多种不同的选项进行设置:本节描述了优先级。

Precedence order (later entries override earlier entries):
优先顺序(后续条目会覆盖先前条目):

  • --env-host : Host environment of the process executing Podman is added.
    --env-host:添加执行 Podman 进程的主机环境。

  • --http-proxy: By default, several environment variables are passed in from the host, such as http_proxy and no_proxy. See --http-proxy for details.
    --http-proxy:默认情况下,从主机传入多个环境变量,如 http_proxy 和 no_proxy。有关详细信息,请参阅 --http-proxy。

  • Container image : Any environment variables specified in the container image.
    容器镜像:容器镜像中指定的任何环境变量。

  • --env-file : Any environment variables specified via env-files. If multiple files specified, then they override each other in order of entry.
    --env-file:通过 env 文件指定的任何环境变量。如果指定了多个文件,则它们按输入顺序互相覆盖。

  • --env : Any environment variables specified overrides previous settings.
    --env:指定的任何环境变量将覆盖先前的设置。

Create containers and set the environment ending with a *. The trailing * glob functionality is only active when no value is specified:
创建容器并设置以 * 结尾的环境。只有在未指定值时,尾随 * 通配符功能才会生效:

$ export ENV1=a
$ podman create --name ctr1 --env 'ENV*' alpine env
$ podman start --attach ctr1 | grep ENV
ENV1=a
$ podman create --name ctr2 --env 'ENV*=b' alpine env
$ podman start --attach ctr2 | grep ENV
ENV*=b

CONMON

When Podman starts a container it actually executes the conmon program, which then executes the OCI Runtime. Conmon is the container monitor. It is a small program whose job is to watch the primary process of the container, and if the container dies, save the exit code. It also holds open the tty of the container, so that it can be attached to later. This is what allows Podman to run in detached mode (backgrounded), so Podman can exit but conmon continues to run. Each container has their own instance of conmon. Conmon waits for the container to exit, gathers and saves the exit code, and then launches a Podman process to complete the container cleanup, by shutting down the network and storage. For more information about conmon, see the conmon(8) man page.
当 Podman 启动容器时,实际上会执行 conmon 程序,然后执行 OCI Runtime。Conmon 是容器监视器。它是一个小程序,其工作是监视容器的主要进程,如果容器停止运行,则保存退出代码。它还保持容器的 tty 打开,以便稍后可以附加到它。这就是允许 Podman 在分离模式(后台运行)下运行的原因,因此 Podman 可以退出,但 conmon 仍然继续运行。每个容器都有自己的 conmon 实例。Conmon 等待容器退出,收集并保存退出代码,然后启动一个 Podman 进程来完成容器清理,关闭网络和存储。有关 conmon 的更多信息,请参阅 conmon(8) 手册页。

FILES 文件 ¶

/etc/subuid /etc/subgid

NOTE: Use the environment variable TMPDIR to change the temporary storage location of downloaded container images. Podman defaults to use /var/tmp.
注意:使用环境变量 TMPDIR 来更改下载容器镜像的临时存储位置。Podman 默认使用 /var/tmp

SEE ALSO 参见 ¶

podman(1), podman-save(1), podman-ps(1), podman-attach(1), podman-pod-create(1), podman-port(1), podman-start(1), podman-kill(1), podman-stop(1), podman-generate-systemd(1), podman-rm(1), subgid(5), subuid(5), containers.conf(5), systemd.unit(5), setsebool(8), slirp4netns(1), pasta(1), fuse-overlayfs(1), proc(5), conmon(8), personality(2)

HISTORY 历史 ¶

October 2017, converted from Docker documentation to Podman by Dan Walsh for Podman <dwalsh@redhat.com>
2017 年 10 月,由 Dan Walsh 将 Docker 文档转换为 Podman <dwalsh@redhat.com>

November 2014, updated by Sven Dowideit <SvenDowideit@home.org.au>
2014 年 11 月,由 Sven Dowideit 更新 <SvenDowideit@home.org.au>

September 2014, updated by Sven Dowideit <SvenDowideit@home.org.au>
2014 年 9 月,由 Sven Dowideit 更新 <SvenDowideit@home.org.au>

August 2014, updated by Sven Dowideit <SvenDowideit@home.org.au>
2014 年 8 月,由 Sven Dowideit 更新 <SvenDowideit@home.org.au>

FOOTNOTES 脚注 ¶

1: The Podman project is committed to inclusivity, a core value of open source. The master and slave mount propagation terminology used here is problematic and divisive, and needs to be changed. However, these terms are currently used within the Linux kernel and must be used as-is at this time. When the kernel maintainers rectify this usage, Podman will follow suit immediately.
1:Podman 项目致力于包容性,这是开源的核心价值观。这里使用的 masterslave 挂载传播术语存在问题和分歧,需要进行更改。然而,这些术语目前在 Linux 内核中使用,因此目前必须按原样使用。当内核维护者纠正这种用法时,Podman 将立即跟进。