NAME¶ 名称
podman-pod-create - Create a new pod
podman-pod-create - 创建一个新的 pod
SYNOPSIS¶ 概要
podman pod create [options] [name]
podman pod create [选项] [名称]
DESCRIPTION¶ 描述
Creates an empty pod, or unit of multiple containers, and prepares it to have
containers added to it. The pod can be created with a specific name. If a name
is not given a random name is generated. The pod ID is printed to STDOUT. You
can then use podman create --pod <pod_id|pod_name>
… to add containers
to the pod, and podman pod start <pod_id|pod_name>
to start the pod.
创建一个空的 pod,或者多个容器的单元,并准备好向其添加容器。可以为 pod 创建一个特定的名称。如果没有给出名称,则会生成一个随机名称。Pod ID 将打印到 STDOUT。然后您可以使用 podman create --pod <pod_id|pod_name>
… 来向 pod 添加容器,并使用 podman pod start <pod_id|pod_name>
来启动 pod。
The operator can identify a pod in three ways:
UUID long identifier (“f78375b1c487e03c9438c729345e54db9d20cfa2ac1fc3494b6eb60872e74778”)
UUID short identifier (“f78375b1c487”)
Name (“jonah”)
运算符可以通过三种方式识别一个 pod:UUID 长标识符(“f78375b1c487e03c9438c729345e54db9d20cfa2ac1fc3494b6eb60872e74778”)UUID 短标识符(“f78375b1c487”)名称(“jonah”)
podman generates a UUID for each pod, and if a name is not assigned
to the container with --name then a random string name is generated
for it. This name is useful to identify a pod.
podman 为每个 pod 生成一个 UUID,如果未使用 --name 为容器分配名称,则会为其生成一个随机字符串名称。这个名称对于识别一个 pod 是有用的。
Note: resource limit related flags work by setting the limits explicitly in the pod’s cgroup parent
for all containers joining the pod. A container can override the resource limits when joining a pod.
For example, if a pod was created via podman pod create --cpus=5, specifying podman container create --pod=<pod_id|pod_name>
--cpus=4 causes the container to use the smaller limit. Also, containers which specify their own cgroup, such as --cgroupns=host, do NOT get the assigned pod level cgroup resources.
注意:与资源限制相关的标志通过在所有加入 pod 的容器的 cgroup 父级中显式设置限制来工作。一个容器可以在加入 pod 时覆盖资源限制。例如,如果通过 podman pod create --cpus=5 创建了一个 pod,指定 podman container create --pod= <pod_id|pod_name>
--cpus=4 会导致容器使用较小的限制。此外,指定自己的 cgroup 的容器,如 --cgroupns=host,不会获得分配的 pod 级 cgroup 资源。
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 选项冲突。
The /etc/hosts file is shared between all containers in the pod.
/etc/hosts 文件在 pod 中的所有容器之间共享。
--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 相对设备权重。
--cgroup-parent=path¶
Path to cgroups under which the cgroup for the pod 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.
创建 Pod 的 cgroup 所在的 cgroups 路径。如果路径不是绝对路径,则将其视为相对于 init 进程的 cgroups 路径。如果这些 cgroups 不存在,则会创建它们。
--cpus=amount¶
Set the total number of CPUs delegated to the pod. Default is 0.000 which indicates that there is no limit on computation power.
设置分配给 pod 的 CPU 总数。默认值为 0.000,表示计算能力没有限制。
--cpuset-cpus=number¶
CPUs in which to allow execution. Can be specified as a comma-separated list
(e.g. 0,1), as a range (e.g. 0-3), or any combination thereof
(e.g. 0-3,7,11-15).
允许执行的 CPU。可以指定为逗号分隔的列表(例如 0,1),作为范围(例如 0-3),或两者的任意组合(例如 0-3,7,11-15)。
On some systems, changing the resource limits may not be allowed for non-root
users. For more details, see
https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error
在某些系统上,非 root 用户可能无法更改资源限制。有关更多详细信息,请参阅 https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error
This option is not supported on cgroups V1 rootless systems.
此选项不支持 cgroups V1 无根系统。
--cpuset-mems=nodes¶
Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on
NUMA systems.
允许执行的内存节点(MEMs)(0-3, 0,1)。仅在 NUMA 系统上有效。
If there are four memory nodes on the system (0-3), use --cpuset-mems=0,1
then processes in the container only uses memory from the first
two memory nodes.
如果系统上有四个内存节点(0-3),则使用--cpuset-mems=0,1,然后容器中的进程仅使用来自前两个内存节点的内存。
On some systems, changing the resource limits may not be allowed for non-root
users. For more details, see
https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error
在某些系统上,非 root 用户可能无法更改资源限制。有关更多详细信息,请参阅 https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error
This option is not supported on cgroups V1 rootless systems.
此选项不支持 cgroups V1 无根系统。
--device=host-device[:container-device][:permissions]¶
--device=主机设备[:容器设备][:权限] ¶
Add a host device to the pod. Optional permissions parameter
can be used to specify device permissions by combining
r for read, w for write, and m for mknod(2).
向 pod 添加主机设备。可选的权限参数可用于通过组合 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 pod only stores the major and minor numbers of the host device.
注意:如果主机设备是符号链接,则首先解析它。Pod 仅存储主机设备的主次编号。
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: the pod implements devices by storing the initial configuration passed by the user and recreating the device on each container added to the pod.
注意:Pod 通过存储用户传递的初始配置并在添加到 Pod 的每个容器上重新创建设备来实现设备。
--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-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 无根系统。
--dns=ipaddr¶
Set custom DNS servers in the /etc/resolv.conf file that is shared between all containers in the pod. A special option, “none” is allowed which disables creation of /etc/resolv.conf for the pod.
在 Pod 中所有容器共享的 /etc/resolv.conf 文件中设置自定义 DNS 服务器。允许使用特殊选项“none”,该选项禁用 Pod 的 /etc/resolv.conf 创建。
--dns-option=option¶
Set custom DNS options in the /etc/resolv.conf file that is shared between all containers in the pod.
在 Pod 中所有容器共享的 /etc/resolv.conf 文件中设置自定义 DNS 选项。
--dns-search=domain¶ --dns-search=域名 ¶
Set custom DNS search domains in the /etc/resolv.conf file that is shared between all containers in the pod.
在 Pod 中所有容器共享的 /etc/resolv.conf 文件中设置自定义 DNS 搜索域。
--exit-policy=continue | stop¶
--exit-policy=continue | stop
Set the exit policy of the pod when the last container exits. Supported policies are:
设置当最后一个容器退出时的 Pod 退出策略。支持的策略有:
Exit Policy 退出策略 |
Description |
---|---|
continue |
The pod continues running, by keeping its infra container alive, when the last container exits. Used by default. |
stop |
The pod (including its infra container) is stopped when the last container exits. Used in |
--gidmap=pod_gid:host_gid:amount¶
GID map for the user namespace. Using this flag runs all containers in the pod with user namespace enabled.
It conflicts with the --userns and --subgidname flags.
用户命名空间的 GID 映射。使用此标志在启用用户命名空间的情况下运行 Pod 中的所有容器。它与 --userns 和 --subgidname 标志冲突。
--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 设备。
--help, -h¶ --help,-h ¶
Print usage statement. 打印使用说明。
--hostname=name¶ --主机名=名称 ¶
Set a hostname to the pod.
为 pod 设置主机名。
--infra¶
Create an infra container and associate it with the pod. An infra container is a lightweight container used to coordinate the shared kernel namespace of a pod. Default: true.
创建一个基础设施容器并将其与 Pod 关联。基础设施容器是一个轻量级容器,用于协调 Pod 的共享内核命名空间。默认值:true。
--infra-command=command¶
--基础设施命令=命令 ¶
The command that is run to start the infra container. Default: “/pause”.
运行基础设施容器的命令。默认值:“/pause”。
--infra-conmon-pidfile=file¶
Write the pid of the infra container’s conmon process to a file. As conmon runs in a separate process than Podman, this is necessary when using systemd to manage Podman containers and pods.
将基础设施容器的 conmon 进程的 pid 写入文件。由于 conmon 运行在与 Podman 不同的进程中,因此在使用 systemd 管理 Podman 容器和 pod 时,这是必要的。
--infra-image=image¶
The custom image that is used for the infra container. Unless specified, Podman builds a custom local image which does not require pulling down an image.
用于基础设施容器的自定义镜像。除非另有指定,Podman 将构建一个自定义本地镜像,不需要拉取镜像。
--infra-name=name¶
The name that is used for the pod’s infra container.
用于 Pod 基础设施容器的名称。
--ip=ipv4¶
Specify a static IPv4 address for the pod, for example 10.88.64.128.
This option can only be used if the pod is joined to only a single network - i.e., --network=network-name is used at most once -
and if the pod 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).
为 pod 指定一个静态 IPv4 地址,例如 10.88.64.128。只有在 pod 仅加入一个网络时才能使用此选项 - 即最多使用一次 --network=network-name - 并且 pod 不通过 --network=container:id 加入另一个容器的网络命名空间。地址必须在网络的 IP 地址池内(默认为 10.88.0.0/16)。
To specify multiple static IP addresses per pod, set multiple networks using the --network option with a static IP address specified for each using the ip
mode for that option.
要为每个 pod 指定多个静态 IP 地址,请使用 --network 选项设置多个网络,并为每个网络使用 ip
模式指定一个静态 IP 地址。
--ip6=ipv6¶ --ip6=ipv6
Specify a static IPv6 address for the pod, for example fd46:db93:aa76:ac37::10.
This option can only be used if the pod is joined to only a single network - i.e., --network=network-name is used at most once -
and if the pod is not joining another container’s network namespace via --network=container:id.
The address must be within the network’s IPv6 address pool.
为 pod 指定一个静态 IPv6 地址,例如 fd46:db93:aa76:ac37::10。只有在 pod 仅加入一个网络时才能使用此选项 - 即最多使用一次 --network=network-name - 并且 pod 不通过 --network=container:id 加入另一个容器的网络命名空间。地址必须在网络的 IPv6 地址池内。
To specify multiple static IPv6 addresses per pod, set multiple networks using the --network option with a static IPv6 address specified for each using the ip6
mode for that option.
要为每个 pod 指定多个静态 IPv6 地址,请使用 --network 选项设置多个网络,并为每个网络使用指定的静态 IPv6 地址,对于该选项使用 ip6
模式。
--label, -l=key=value¶ --label,-l=key=value ¶
Add metadata to a pod.
向 Pod 添加元数据。
--label-file=file¶
Read in a line-delimited file of labels.
读取一个以行分隔的标签文件。
--mac-address=address¶
Pod network interface MAC address (e.g. 92:d0:c6:0a:29:33)
This option can only be used if the pod is joined to only a single network - i.e., --network=network-name is used at most once -
and if the pod is not joining another container’s network namespace via --network=container:id.
Pod 网络接口 MAC 地址(例如 92:d0:c6:0a:29:33)此选项仅在 pod 仅加入单个网络时才能使用 - 即,最多使用一次 --network=network-name - 并且如果 pod 不通过 --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 pod, set multiple networks using the --network option with a static MAC address specified for each using the mac
mode for that option.
要为每个 pod 指定多个静态 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-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 无根系统。
--name, -n=name¶
Assign a name to the pod.
为 pod 分配一个名称。
--network=mode, --net¶
Set the network mode for the pod.
设置 pod 的网络模式。
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, usually10.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 thetap0
interface in the container, with gateway10.0.2.3
, enable DNS forwarder reachable at10.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 无效。
--network-alias=alias¶
Add a network-scoped alias for the pod, 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 pod only has access to aliases on the first network that it joins. This limitation does
not exist with netavark/aardvark-dns.
为 pod 添加一个网络范围的别名,为容器加入的所有网络设置别名。要仅为特定网络设置名称,请使用别名选项,如在 --network 选项下所述。如果网络启用了 DNS( podman network inspect -f {{.DNSEnabled}} <name>
),则这些别名可用于在给定网络上进行名称解析。此选项可以多次指定。注意:使用 CNI 时,一个 pod 只能访问它加入的第一个网络上的别名。这种限制在 netavark/aardvark-dns 中不存在。
--no-hosts¶
Do not create /etc/hosts for the pod.
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.
不为 pod 创建 /etc/hosts。默认情况下,Podman 管理 /etc/hosts,添加容器自己的 IP 地址和任何来自 --add-host 的主机。--no-hosts 禁用此功能,并保留镜像的 /etc/hosts 不受修改。
This option conflicts with --add-host.
此选项与 --add-host 冲突。
--pid=pid¶
Set the PID mode for the pod. The default is to create a private PID namespace for the pod. Requires the PID namespace to be shared via --share.
为 Pod 设置 PID 模式。默认情况下,为 Pod 创建一个私有 PID 命名空间。需要通过 --share 共享 PID 命名空间。
host: use the host’s PID namespace for the pod
ns: join the specified PID namespace
private: create a new namespace for the pod (default)
--pod-id-file=path¶ --pod-id-file=path
Write the pod ID to the file.
将 pod ID 写入文件。
--publish, -p=[[ip:][hostPort]:]containerPort[/protocol]¶
Publish a container’s port, or range of ports, within this pod to the host.
将此 pod 中容器的端口或端口范围发布到主机。
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
两次,分别使用 tcp
和 udp
作为协议。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.
请注意,网络驱动程序 macvlan
和 ipvlan
不支持端口转发,在这些网络上不会产生任何影响。
Note: You must not publish ports of containers in the pod individually,
but only by the pod itself.
注意:您不能单独发布 pod 中容器的端口,而只能通过 pod 本身来发布。
Note: This cannot be modified once the pod is created.
注意:一旦创建了 Pod,就无法修改此项。
--replace¶ --替换 ¶
If another pod with the same name already exists, replace and remove it. The default is false.
如果已经存在同名的另一个 Pod,则替换并移除它。默认值为 false。
--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)。
Default restart policy for all the containers in a pod.
Pod 中所有容器的默认重启策略。
--security-opt=option¶ --security-opt=option
Security Options 安全选项
apparmor=unconfined : Turn off apparmor confinement for the pod
apparmor=unconfined:为 pod 关闭 apparmor 限制apparmor=alternate-profile : Set the apparmor confinement profile for the pod
apparmor=alternate-profile:为 pod 设置 apparmor 限制配置文件label=user:USER: Set the label user for the pod processes
label=user:USER:为 pod 进程设置用户标签label=role:ROLE: Set the label role for the pod processes
标签=角色: 为 pod 进程设置标签角色label=type:TYPE: Set the label process type for the pod processes
标签=类型: 为 pod 进程设置标签进程类型label=level:LEVEL: Set the label level for the pod processes
标签=级别: 为 pod 进程设置标签级别label=filetype:TYPE: Set the label file type for the pod files
标签=filetype:类型: 为 pod 文件设置标签文件类型label=disable: Turn off label separation for the pod
标签=disable: 关闭 pod 的标签分离
Note: Labeling can be disabled for all pods/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 来禁用所有 pods/containers 的标签化。
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 containers within the pod.
mask=/path/1:/path/2:由冒号分隔的要屏蔽的路径。在 Pod 内的容器中无法访问被屏蔽的路径。no-new-privileges: Disable container processes from gaining additional privileges.
no-new-privileges: 禁止容器进程获取额外的特权。seccomp=unconfined: Turn off seccomp confinement for the pod.
seccomp=unconfined:为 Pod 关闭 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 inpodman 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 pod.
This option conflicts with --ipc=host.
/dev/shm 的大小。单位可以是 b(字节)、k(kibibytes)、m(mebibytes)或 g(gibibytes)。如果省略单位,则系统使用字节。如果省略大小,则默认为 64m。当大小为 0 时,Pod 使用的 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%。
--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 for all containers in the pod.
为 Pod 中的所有容器配置命名空间内核参数。
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 the ipc namespace is not shared within the pod, the above sysctls are not allowed.
注意:如果 IPC 命名空间在 Pod 内部不共享,则上述 sysctl 是不允许的。
For the network namespace, only sysctls beginning with net.* are allowed.
对于网络命名空间,只允许使用以 net.* 开头的 sysctl。
Note: if the network namespace is not shared within the pod, the above sysctls are not allowed.
注意:如果网络命名空间在 pod 中不共享,则上述 sysctl 是不允许的。
--uidmap=container_uid:from_uid:amount¶
Run all containers in the pod in a new user namespace using the supplied 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.
在新的用户命名空间中使用提供的映射运行 pod 中的所有容器。此选项与 --userns 和 --subuidname 选项冲突。此选项提供了一种将主机 UID 映射到容器 UID 的方法。可以多次传递此选项以映射不同的范围。
--userns=mode¶ --userns=mode
Set the user namespace mode for all the containers in a pod. It defaults to the PODMAN_USERNS
environment variable. An empty value (“”) means user namespaces are disabled.
为 Pod 中的所有容器设置用户命名空间模式。默认为 PODMAN_USERNS
环境变量。空值(“”)表示用户命名空间已禁用。
Rootless user --userns=Key mappings:
无根用户--userns=Key 映射:
Key |
Host User 主机用户 |
Container User 容器用户 |
---|---|---|
“” |
$UID |
0 (Default User account mapped to root user in container.) |
host |
$UID |
0 (Default User account mapped to root user in container.) |
keep-id |
$UID |
$UID (Map user account to same UID within container.) |
auto |
$UID |
nil (Host User UID is not mapped into container.) |
nomap |
$UID |
nil (Host User UID is not mapped into container.) |
Valid mode values are: 有效的模式值为:
auto[:OPTIONS,…]: automatically create a namespace. It is possible to specify these options to
auto
:
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
. Ifsize
is not specified,auto
estimates the size for the user namespace.
size=SIZE: 为自动用户命名空间指定显式大小。例如--userns=auto:size=8192
。如果未指定size
,auto
会为用户命名空间估算大小。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 映射。
host: 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 (default).
主机:在调用者的用户命名空间中运行。在容器中运行的进程在主机上具有与调用用户启动的任何其他进程相同的特权(默认)。keep-id: creates a user namespace where the current rootless user’s UID:GID are mapped to the same values in the container. This option is not allowed for containers created by the root user.
保持 ID:创建一个用户命名空间,其中当前无根用户的 UID:GID 映射到容器中的相同值。此选项不允许由 root 用户创建的容器使用。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 用户创建的容器使用。
--uts=mode¶
Set the UTS namespace mode for the pod. The following values are supported:
设置 pod 的 UTS 命名空间模式。支持以下值:
host: use the host’s UTS namespace inside the pod.
主机:在 pod 内部使用主机的 UTS 命名空间。private: create a new namespace for the pod (default).
私有:为 pod 创建一个新的命名空间(默认)。ns:[path]: run the pod in the given existing UTS namespace.
ns:[路径]:在给定的现有 UTS 命名空间中运行 pod。
--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 pod 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
命令删除 pod 时被删除。
(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
pod.
指定多个-v 选项将一个或多个卷挂载到一个 pod 中。
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 pod 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 不会更改挂载到容器中的源卷目录的所有者和组。如果在新的用户命名空间中创建了一个 pod,容器中的 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 pod, 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 pod.
" :U
"后缀告诉 Podman 根据 pod 中的 UID 和 GID 使用正确的主机 UID 和 GID,递归更改源卷的所有者和组。Chowning 遍历卷下的文件系统,并更改每个文件的 UID/GID。如果卷有数千个 inode,则此过程需要很长时间,延迟 pod 的启动。
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 pod. Without a label, the security system
might prevent the processes running inside the pod from using the
content. By default, Podman does not change the labels set by the OS.
像 SELinux 这样的标记系统要求在挂载到 pod 中的卷内容上放置适当的标记。如果没有标记,安全系统可能会阻止在 pod 内部运行的进程使用内容。默认情况下,Podman 不会更改操作系统设置的标签。
To change a label in the pod 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
pods 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 pod 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 pod. 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.
要在 pod 上下文中更改标签,请在卷挂载中添加两个后缀之一::z 或 :Z。这些后缀告诉 Podman 在共享卷上重新标记文件对象。z 选项告诉 Podman 两个或更多个 pod 共享卷内容。因此,Podman 使用共享内容标签标记内容。共享卷标签允许所有容器读取/写入内容。Z 选项告诉 Podman 使用私有未共享标签标记内容。只有当前 pod 可以使用私有卷。重新标记会遍历卷下的文件系统,并更改每个文件的标签,如果卷有数千个 inode,则此过程需要很长时间,延迟 pod 的启动。如果卷之前使用 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 pod.
For example if a user wanted to volume mount their entire home directory into a
pod, they need to disable SELinux separation.
注意: 不要重新标记系统文件和目录。重新标记系统内容可能导致机器上其他受限服务失败。对于这些类型的容器,我们建议禁用 SELinux 分离。选项 --security-opt label=disable 会为 pod 禁用 SELinux 分离。例如,如果用户想要将他们整个家目录挂载到一个 pod 中,他们需要禁用 SELinux 分离。
$ podman pod 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 pod 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 pod
finishes executing, similar to a tmpfs mount point being unmounted.
:O
标志告诉 Podman 将主机上的目录作为临时存储挂载,使用 overlay file system
。pod 进程可以修改挂载点内的内容,该内容存储在容器存储中的一个单独目录中。在叠加术语中,源目录是下层,容器存储目录是上层。对挂载点的修改在 pod 执行完成时被销毁,类似于 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 pod executions no longer exist.
容器的后续执行会看到原始源目录内容,之前 pod 执行的任何更改都不再存在。
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 pod infra 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 pod or infra container
to work.
安装到容器中的内容带有私有标签。在 SELinux 系统上,源目录中的标签必须可被 pod 基础设施容器标签读取。通常容器可以读取/执行 container_share_t
并且可以读取/写入 container_file_t
。如果无法更改源卷上的标签,则必须为 pod 或基础设施容器禁用 SELinux 容器隔离才能正常工作。
Do not modify the source directory mounted into the pod with an overlay mount,
it can cause unexpected failures. Only modify the directory after the container finishes running.
不要使用覆盖挂载修改挂载到 pod 中的源目录,这可能会导致意外故障。只能在容器运行完成后修改目录。
Mounts propagation
By default, bind-mounted volumes are private
. That means any mounts done
inside the pod 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 pod
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
。这意味着在 pod 内部进行的任何挂载对主机都不可见,反之亦然。可以通过指定卷挂载传播属性来更改此行为。当一个卷是 shared
时,在 pod 内部该卷下进行的挂载对主机可见,反之亦然。将卷设置为 slave [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
pod, use the rbind option. By default the bind option is
used, and submounts of the source directory is not mounted into the
pod.
为了递归地将一个卷及其所有子卷挂载到一个 pod 中,使用 rbind 选项。默认情况下使用 bind 选项,并且源目录的子卷不会被挂载到 pod 中。
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 pod.
使用 noexec 选项挂载卷意味着卷上的可执行文件不能在 pod 中执行。
Mounting the volume with the nodev option means that no devices on the volume
can be used by processes within the pod. By default volumes
are mounted with nodev.
使用 nodev 选项挂载卷意味着卷上的设备不能被 pod 内的进程使用。默认情况下,卷是以 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 pod fails.
注意: 如果用户仅通过组具有访问权限,则无法从无根 pod 内部访问卷。
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 的起始值。此映射的长度在第三个值中给出。多个范围用 # 分隔。
--volumes-from=CONTAINER[:OPTIONS]¶
Mount volumes from the specified container(s). Used to share volumes between
containers and pods. The options is a comma-separated list with the following available elements:
从指定的容器中挂载卷。用于在容器和 pod 之间共享卷。选项是一个逗号分隔的列表,包含以下可用元素:
rw|ro 读写|只读
z
Mounts already mounted volumes from a source container onto another
pod. 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.
将已经挂载的卷从源容器挂载到另一个 pod 上。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 以与源容器中挂载的模式(读写或只读)相同的模式挂载卷。可以通过添加 ro
或 rw
选项来更改这一点。
Labeling systems like SELinux require that proper labels are placed on volume
content mounted into a pod. 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 这样的标签系统要求在挂载到 Pod 中的卷内容上放置适当的标签。如果没有标签,安全系统可能会阻止容器内运行的进程使用内容。默认情况下,Podman 不会更改操作系统设置的标签。
To change a label in the pod 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.
要在 pod 上下文中更改标签,请将 z
添加到卷挂载中。此后缀告诉 Podman 重新标记共享卷上的文件对象。 z
选项告诉 Podman 两个实体共享卷内容。因此,Podman 使用共享内容标签标记内容。共享卷标签允许所有容器读取/写入内容。
If the location of the volume from the source container overlaps with
data residing on a target pod, then the volume hides
that data on the target.
如果源容器中卷的位置与目标 pod 上的数据重叠,则该卷会隐藏目标上的数据。
EXAMPLES¶ 示例
Create a named pod.
创建一个命名的 pod。
$ podman pod create --name test
Create a named pod.
创建一个命名的 pod。
$ podman pod create mypod
Create a pod without an infra container.
创建一个没有基础设施容器的 Pod。
$ podman pod create --infra=false
Create a named pod with infra container command to run.
创建一个带有基础设施容器命令运行的命名 Pod。
$ podman pod create --infra-command /top toppod
Create a pod with published ports on the host.
在主机上创建一个具有发布端口的 Pod。
$ podman pod create --publish 8443:443
Create a pod with the specified network configuration.
使用指定的网络配置创建一个 Pod。
$ podman pod create --network slirp4netns:outbound_addr=127.0.0.1,allow_host_loopback=true
Create a pod with the specified network.
使用指定的网络创建一个 Pod。
$ podman pod create --network pasta
Create a pod on two networks.
在两个网络上创建一个 Pod。
$ podman pod create --network net1:ip=10.89.1.5 --network net2:ip=10.89.10.10
SEE ALSO¶ 参见 ¶
podman(1), podman-pod(1), podman-kube-play(1), containers.conf(1), cgroups(7)
HISTORY¶ 历史 ¶
July 2018, Originally compiled by Peter Hunt pehunt@redhat.com
2018 年 7 月,最初由 Peter Hunt pehunt@redhat.com 编译
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 项目致力于包容性,这是开源的核心价值观。这里使用的 master
和 slave
挂载传播术语存在问题和分歧,需要进行更改。然而,这些术语目前在 Linux 内核中使用,因此目前必须按原样使用。当内核维护者纠正这种用法时,Podman 将立即跟进。