NAME¶ 名称
podman - Simple management tool for pods, containers and images
Podman - 用于管理 Pod、容器和镜像的简单工具
SYNOPSIS¶ 概要
podman [options] command podman [选项] 命令
DESCRIPTION¶ 描述
Podman (Pod Manager) is a fully featured container engine that is a simple daemonless tool.
Podman provides a Docker-CLI comparable command line that eases the transition from other
container engines and allows the management of pods, containers and images. Simply put: alias docker=podman
.
Most Podman commands can be run as a regular user, without requiring additional
privileges.
Podman(Pod 管理器)是一个功能齐全的容器引擎,是一个简单的无守护进程工具。Podman 提供了类似 Docker-CLI 的命令行,有助于从其他容器引擎过渡,并允许管理 Pod、容器和镜像。简而言之: alias docker=podman
。大多数 Podman 命令可以作为普通用户运行,无需额外权限。
Podman uses Buildah(1) internally to create container images. Both tools share image
(not container) storage, hence each can use or manipulate images (but not containers)
created by the other.
Podman 在内部使用 Buildah(1)来创建容器镜像。这两个工具共享镜像(而不是容器)存储,因此每个工具都可以使用或操作另一个工具创建的镜像(但不能操作容器)。
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,除非在手册页中有记录。
podman [GLOBAL OPTIONS] podman [全局选项]
GLOBAL OPTIONS¶ 全局选项 ¶
--cgroup-manager=manager¶
--cgroup-manager=manager
The CGroup manager to use for container cgroups. Supported values are cgroupfs or systemd. Default is systemd unless overridden in the containers.conf file.
用于容器 cgroups 的 CGroup 管理器。支持的值为 cgroupfs 或 systemd。默认值为 systemd,除非在 containers.conf 文件中被覆盖。
Note: Setting this flag can cause certain commands to break when called on containers previously created by the other CGroup manager type.
Note: CGroup manager is not supported in rootless mode when using CGroups Version V1.
注意: 设置此标志可能会导致在先前由其他 CGroup 管理器类型创建的容器上调用某些命令时出现故障。注意: 在使用 CGroups 版本 V1 时,CGroup 管理器在无根模式下不受支持。
--config¶ --配置 ¶
Location of config file. Mainly for docker compatibility, only the authentication parts of the config are supported.
配置文件的位置。主要用于 Docker 兼容性,仅支持配置的身份验证部分。
--conmon¶
Path of the conmon binary (Default path is configured in containers.conf
)
通用二进制文件的路径(默认路径配置在 containers.conf
中)
--connection, -c¶ --connection,-c ¶
Connection to use for remote podman, including Mac and Windows (excluding WSL2) machines, (Default connection is configured in containers.conf
)
Setting this option switches the --remote option to true.
Remote connections use local containers.conf for default.
用于远程 podman 的连接,包括 Mac 和 Windows(不包括 WSL2)机器,(默认连接配置在 containers.conf
中)设置此选项会将 --remote 选项切换为 true。远程连接使用本地 containers.conf 作为默认设置。
--events-backend=type¶
Backend to use for storing events. Allowed values are file, journald, and
none. When file is specified, the events are stored under
<tmpdir>/events/events.log
(see --tmpdir below).
用于存储事件的后端。允许的值为文件、journald 和无。当指定文件时,事件存储在 <tmpdir>/events/events.log
下(请参阅下面的 --tmpdir)。
--help, -h¶ --help,-h ¶
Print usage statement 打印使用说明
--hooks-dir=path¶
Each *.json
file in the path configures a hook for Podman containers. For more details on the syntax of the JSON files and the semantics of hook injection, see oci-hooks(5)
. Podman and libpod currently support both the 1.0.0 and 0.1.0 hook schemas, although the 0.1.0 schema is deprecated.
路径中的每个 *.json
文件配置了 Podman 容器的钩子。有关 JSON 文件语法和钩子注入语义的详细信息,请参见 oci-hooks(5)
。Podman 和 libpod 目前支持 1.0.0 和 0.1.0 两种钩子模式,尽管 0.1.0 模式已被弃用。
This option may be set multiple times; paths from later options have higher precedence (oci-hooks(5)
discusses directory precedence).
此选项可以设置多次;后续选项的路径具有更高的优先级( oci-hooks(5)
讨论目录优先级)。
For the annotation conditions, libpod uses any annotations set in the generated OCI configuration.
对于注释条件,libpod 使用在生成的 OCI 配置中设置的任何注释。
For the bind-mount conditions, only mounts explicitly requested by the caller via --volume
are considered. Bind mounts that libpod inserts by default (e.g. /dev/shm
) are not considered.
对于绑定挂载条件,只考虑调用者通过 --volume
显式请求的挂载。libpod 默认插入的绑定挂载(例如 /dev/shm
)不予考虑。
If --hooks-dir
is unset for root callers, Podman and libpod currently default to /usr/share/containers/oci/hooks.d
and /etc/containers/oci/hooks.d
in order of increasing precedence. Using these defaults is deprecated. Migrate to explicitly setting --hooks-dir
.
如果根调用方未设置 --hooks-dir
,Podman 和 libpod 目前会按照递增优先级默认为 /usr/share/containers/oci/hooks.d
和 /etc/containers/oci/hooks.d
。使用这些默认值已被弃用。请迁移到显式设置 --hooks-dir
。
Podman and libpod currently support an additional precreate
state which is called before the runtime’s create
operation. Unlike the other stages, which receive the container state on their standard input, precreate
hooks receive the proposed runtime configuration on their standard input. They may alter that configuration as they see fit, and write the altered form to their standard output.
Podman 和 libpod 目前支持一个额外的 precreate
状态,称为运行时 create
操作之前的状态。与其他阶段不同,这些 precreate
钩子在标准输入上接收建议的运行时配置,可以根据需要修改该配置,并将修改后的形式写入标准输出。
WARNING: the precreate
hook allows powerful changes to occur, such as adding additional mounts to the runtime configuration. That power also makes it easy to break things. Before reporting libpod errors, try running a container with precreate
hooks disabled to see if the problem is due to one of the hooks.
警告: precreate
钩子允许发生强大的更改,例如向运行时配置添加额外的挂载点。这种强大功能也使得容易出现故障。在报告 libpod 错误之前,请尝试禁用 precreate
钩子运行容器,以查看问题是否由其中一个钩子引起。
--identity=path¶
Path to ssh identity file. If the identity file has been encrypted, podman prompts the user for the passphrase.
If no identity file is provided and no user is given, podman defaults to the user running the podman command.
Podman prompts for the login password on the remote server.
SSH 身份文件的路径。如果身份文件已加密,podman 会提示用户输入密码。如果未提供身份文件且未指定用户,则 podman 默认使用运行 podman 命令的用户。Podman 会提示在远程服务器上输入登录密码。
Identity value resolution precedence:
身份值解析优先级:
command line value 命令行值
environment variable
CONTAINER_SSHKEY
, ifCONTAINER_HOST
is found
环境变量CONTAINER_SSHKEY
,如果找到CONTAINER_HOST
containers.conf
Remote connections use local containers.conf for default.
containers.conf
远程连接使用本地 containers.conf 作为默认。
--imagestore=path¶
Path of the imagestore where images are stored. By default, the storage library stores all the images in the graphroot but if an imagestore is provided, then the storage library will store newly pulled images in the provided imagestore and keep using the graphroot for everything else. If the user is using the overlay driver, then the images which were already part of the graphroot will still be accessible.
存储图像的图像存储库路径。默认情况下,存储库将所有图像存储在图形根目录中,但如果提供了图像存储库,则存储库将在提供的图像存储库中存储新拉取的图像,并继续使用图形根目录进行其他操作。如果用户使用叠加驱动程序,则图形根目录中已经存在的图像仍将可访问。
This will override imagestore option in containers-storage.conf(5)
, refer to containers-storage.conf(5)
for more details.
这将覆盖 containers-storage.conf(5)
中的 imagestore 选项,请参考 containers-storage.conf(5)
了解更多详情。
--log-level=level¶ --日志级别=级别 ¶
Log messages at and above specified level: debug, info, warn, error, fatal or panic (default: warn)
记录消息在指定级别及以上:调试,信息,警告,错误,致命或恐慌(默认:警告)
--module=path¶ --模块=路径 ¶
Load the specified containers.conf(5)
module. Can be an absolute or relative path. Please refer to containers.conf(5)
for details.
加载指定的 containers.conf(5)
模块。可以是绝对路径或相对路径。请参考 containers.conf(5)
了解详情。
This flag is not supported on the remote client, including Mac and Windows (excluding WSL2) machines.
Further note that the flag is a root-level flag and must be specified before any Podman sub-command.
此标志不受远程客户端支持,包括 Mac 和 Windows(不包括 WSL2)机器。进一步注意,该标志是根级标志,必须在任何 Podman 子命令之前指定。
--network-cmd-path=path¶
Path to the slirp4netns(1)
command binary to use for setting up a slirp4netns network.
If “” is used, then the binary will first be searched using the helper_binaries_dir
option in containers.conf
, and second using the $PATH
environment variable.
Note: This option is deprecated and will be removed with Podman 5.0. Use the helper_binaries_dir
option in containers.conf
instead.
用于设置 slirp4netns 网络的 slirp4netns(1)
命令二进制文件的路径。如果使用“”,则首先将使用 helper_binaries_dir
选项在 containers.conf
中搜索二进制文件,然后使用 $PATH
环境变量。注意:此选项已弃用,并将在 Podman 5.0 中删除。请改用 helper_binaries_dir
选项在 containers.conf
中。
--network-config-dir=directory¶
Path to the directory where network configuration files are located.
For the netavark backend “/etc/containers/networks” is used as root
and “$graphroot/networks” as rootless.
For the CNI backend the default is “/etc/cni/net.d” as root
and “$HOME/.config/cni/net.d” as rootless.
CNI is deprecated and will be removed in the next major Podman version 5.0 in preference of Netavark.
存放网络配置文件的目录路径。对于 netavark 后端,“/etc/containers/networks” 用作根目录,“$graphroot/networks” 用作无根目录。对于 CNI 后端,默认值为“/etc/cni/net.d” 用作根目录,“$HOME/.config/cni/net.d” 用作无根目录。CNI 已弃用,并将在下一个主要 Podman 版本 5.0 中被 Netavark 取代。
--out=path¶
Redirect the output of podman to the specified path without affecting the container output or its logs. This parameter can be used to capture the output from any of podman’s commands directly into a file and enable suppression of podman’s output by specifying /dev/null as the path. To explicitly disable the container logging, the --log-driver option should be used.
将 podman 的输出重定向到指定路径,而不影响容器的输出或日志。此参数可用于直接将 podman 的任何命令输出捕获到文件中,并通过指定 /dev/null 作为路径来启用对 podman 输出的抑制。要显式禁用容器日志记录,应使用 --log-driver 选项。
--remote, -r¶
When true, access to the Podman service is remote. Defaults to false.
Settings can be modified in the containers.conf file. If the CONTAINER_HOST
environment variable is set, the --remote option defaults to true.
当为 true 时,对 Podman 服务的访问是远程的。默认值为 false。设置可以在 containers.conf 文件中修改。如果设置了 CONTAINER_HOST 环境变量,则--remote 选项默认为 true。
--root=value¶
Storage root dir in which data, including images, is stored (default: “/var/lib/containers/storage” for UID 0, “$HOME/.local/share/containers/storage” for other users).
Default root dir configured in containers-storage.conf(5)
.
存储根目录,其中包括数据和镜像的存储位置(默认值为“/var/lib/containers/storage”对于 UID 0,“$HOME/.local/share/containers/storage”对于其他用户)。默认根目录配置在 containers-storage.conf(5)
中。
Overriding this option causes the storage-opt settings in containers-storage.conf(5)
to be ignored. The user must specify additional options via the --storage-opt
flag.
覆盖此选项会导致 containers-storage.conf(5)
中的存储选项被忽略。用户必须通过 --storage-opt
标志指定其他选项。
--runroot=value¶
Storage state directory where all state information is stored (default: “/run/containers/storage” for UID 0, “/run/user/$UID/run” for other users).
Default state dir configured in containers-storage.conf(5)
.
存储状态目录,其中存储所有状态信息(默认值为“/run/containers/storage”对于 UID 0,“/run/user/$UID/run”对于其他用户)。默认状态目录配置在 containers-storage.conf(5)
中。
--runtime=value¶
Name of the OCI runtime as specified in containers.conf or absolute path to the OCI compatible binary used to run containers.
在 containers.conf 中指定的 OCI 运行时的名称,或者用于运行容器的 OCI 兼容二进制文件的绝对路径。
--runtime-flag=flag¶
Adds global flags for the container runtime. To list the supported flags, please
consult the manpages of the selected container runtime (runc
is the default
runtime, the manpage to consult is runc(8)
. When the machine is configured
for cgroup V2, the default runtime is crun
, the manpage to consult is crun(8)
.).
为容器运行时添加全局标志。要列出支持的标志,请参阅所选容器运行时的 man 手册( runc
是默认运行时,要查阅的 man 手册是 runc(8)
。当机器配置为 cgroup V2 时,默认运行时是 crun
,要查阅的 man 手册是 crun(8)
)。
Note: Do not pass the leading --
to the flag. To pass the runc flag --log-format json
to podman build, the option given can be --runtime-flag log-format=json
.
注意:不要将前导 --
传递给标志。要将 runc 标志 --log-format json
传递给 podman build,可以使用给定的选项 --runtime-flag log-format=json
。
--ssh=value¶
This option allows the user to change the ssh mode, meaning that rather than using the default golang mode, one can instead use --ssh=native
to use the installed ssh binary and config file declared in containers.conf.
此选项允许用户更改 ssh 模式,这意味着可以使用 --ssh=native 而不是使用默认的 golang 模式,以使用安装的 ssh 二进制文件和在 containers.conf 中声明的配置文件。
--storage-driver=value¶
Storage driver. The default storage driver for UID 0 is configured in containers-storage.conf(5)
in rootless mode), and is vfs for non-root users when fuse-overlayfs is not available. The STORAGE_DRIVER
environment variable overrides the default. The --storage-driver specified driver overrides all.
存储驱动程序。在无根模式下,UID 0 的默认存储驱动程序配置在 containers-storage.conf(5)
中,并且在 fuse-overlayfs 不可用时,非根用户的默认存储驱动程序是 vfs。 STORAGE_DRIVER
环境变量会覆盖默认设置。指定的 --storage-driver 驱动程序会覆盖所有设置。
Overriding this option causes the storage-opt settings in containers-storage.conf(5)
to be ignored. The user must
specify additional options via the --storage-opt
flag.
覆盖此选项会导致 containers-storage.conf(5)
中的存储选项设置被忽略。用户必须通过 --storage-opt
标志指定额外选项。
--storage-opt=value¶
Specify a storage driver option. Default storage driver options are configured in containers-storage.conf(5)
. The STORAGE_OPTS
environment variable overrides the default. The --storage-opt specified options override all. Specify --storage-opt=”” so no storage options is used.
指定存储驱动程序选项。默认存储驱动程序选项在 containers-storage.conf(5)
中配置。 STORAGE_OPTS
环境变量会覆盖默认设置。--storage-opt 指定的选项会覆盖所有设置。指定--storage-opt=””表示不使用任何存储选项。
--syslog¶
Output logging information to syslog as well as the console (default false).
将输出日志信息到 syslog 以及控制台(默认为 false)。
On remote clients, including Mac and Windows (excluding WSL2) machines, logging is directed to the file $HOME/.config/containers/podman.log.
在远程客户端,包括 Mac 和 Windows(不包括 WSL2)机器上,日志被定向到文件 $HOME/.config/containers/podman.log。
--tmpdir=path¶
Path to the tmp directory, for libpod runtime content. Defaults to $XDG_RUNTIME_DIR/libpod/tmp
as rootless and /run/libpod/tmp
as rootful.
临时目录的路径,用于 libpod 运行时内容。默认为 $XDG_RUNTIME_DIR/libpod/tmp
作为无根用户和 /run/libpod/tmp
作为有根用户。
NOTE --tmpdir is not used for the temporary storage of downloaded images. Use the environment variable TMPDIR
to change the temporary storage location of downloaded container images. Podman defaults to use /var/tmp
.
注意 --tmpdir 不用于下载镜像的临时存储。使用环境变量 TMPDIR
来更改下载容器镜像的临时存储位置。Podman 默认使用 /var/tmp
。
--transient-store¶ --transient-store
Enables a global transient storage mode where all container metadata is stored on non-persistent media (i.e. in the location specified by --runroot
).
This mode allows starting containers faster, as well as guaranteeing a fresh state on boot in case of unclean shutdowns or other problems. However
it is not compatible with a traditional model where containers persist across reboots.
启用全局瞬态存储模式,在此模式下,所有容器元数据存储在非持久性介质上(即在 --runroot
指定的位置)。此模式允许更快地启动容器,并在不干净的关闭或其他问题的情况下保证引导时的新状态。但它与容器跨重启持久的传统模型不兼容。
Default value for this is configured in containers-storage.conf(5)
.
此项的默认值在 containers-storage.conf(5)
中配置。
--url=value¶
URL to access Podman service (default from containers.conf
, rootless unix:///run/user/$UID/podman/podman.sock
or as root unix:///run/podman/podman.sock
).
Setting this option switches the --remote option to true.
访问 Podman 服务的 URL(默认来自 containers.conf
,无根 unix:///run/user/$UID/podman/podman.sock
或作为 root unix:///run/podman/podman.sock
)。设置此选项会将 --remote 选项切换为 true。
CONTAINER_HOST
is of the format<schema>://[<user[:<password>]@]<host>[:<port>][<path>]
CONTAINER_HOST
的格式为<schema>://[<user[:<password>]@]<host>[:<port>][<path>]
Details: 详情:
schema
is one of:schema
是以下之一:ssh
(default): a local unix(7) socket on the namedhost
andport
, reachable via SSH
ssh
(默认):位于命名为host
和port
上的本地 unix(7) 套接字,可通过 SSH 访问tcp
: an unencrypted, unauthenticated TCP connection to the namedhost
andport
tcp
:与命名为host
和port
的主机之间的未加密、未认证的 TCP 连接unix
: a local unix(7) socket at the specifiedpath
, or the default for the user
unix
:指定的path
处的本地 Unix(7) 套接字,或用户的默认值
user
defaults to eitherroot
or the current running user (ssh
only)
user
默认为root
或当前运行用户(仅ssh
)password
has no default (ssh
only)
password
没有默认值(仅ssh
)host
must be provided and is either the IP or name of the machine hosting the Podman service (ssh
andtcp
)
host
必须提供,并且是托管 Podman 服务的机器的 IP 或名称(ssh
和tcp
)port
defaults to 22 (ssh
andtcp
)
port
默认为 22(ssh
和tcp
)path
defaults to either/run/podman/podman.sock
, or/run/user/$UID/podman/podman.sock
if running rootless (unix
), or must be explicitly specified (ssh
)
path
默认为/run/podman/podman.sock
,或者如果以非 root 用户身份运行则为/run/user/$UID/podman/podman.sock
(unix
),或必须明确指定(ssh
)
URL value resolution precedence:
URL 值解析优先级:
command line value 命令行值
environment variable
CONTAINER_HOST
环境变量CONTAINER_HOST
engine.service_destinations
table in containers.conf, excluding the /usr/share/containers directory
在 containers.conf 中的engine.service_destinations
表中,不包括 /usr/share/containers 目录unix:///run/podman/podman.sock
Remote connections use local containers.conf for default.
远程连接使用本地 containers.conf 作为默认设置。
Some example URL values in valid formats:
一些有效格式的示例 URL 值:
unix:///run/podman/podman.sock
unix:///run/user/$UID/podman/podman.sock
ssh://notroot@localhost:22/run/user/$UID/podman/podman.sock
ssh://root@localhost:22/run/podman/podman.sock
tcp://localhost:34451
tcp://127.0.0.1:34451
--version, -v¶ --版本, -v ¶
Print the version 打印版本
--volumepath=value¶ --卷路径=值 ¶
Volume directory where builtin volume information is stored (default: “/var/lib/containers/storage/volumes” for UID 0, “$HOME/.local/share/containers/storage/volumes” for other users). Default volume path can be overridden in containers.conf
.
存储内置卷信息的卷目录(默认值为“/var/lib/containers/storage/volumes”对于 UID 0,“$HOME/.local/share/containers/storage/volumes”对于其他用户)。默认卷路径可以在 containers.conf
中被覆盖。
Environment Variables¶ 环境变量
Podman can set up environment variables from env of [engine] table in containers.conf. These variables can be overridden by passing environment variables before the podman
commands.
Podman 可以从 containers.conf 中 [engine] 表的 env 设置环境变量。这些变量可以通过在 podman
命令之前传递环境变量来覆盖。
CONTAINERS_CONF¶
Set default locations of containers.conf file
设置容器配置文件的默认位置
CONTAINERS_REGISTRIES_CONF¶
Set default location of the registries.conf file.
设置 registries.conf 文件的默认位置。
CONTAINERS_STORAGE_CONF¶
CONTAINERS_STORAGE_CONF
Set default location of the storage.conf file.
设置 storage.conf 文件的默认位置。
CONTAINER_CONNECTION¶ 容器连接
Override default --connection
value to access Podman service. Automatically enables the --remote option.
覆盖默认 --connection
值以访问 Podman 服务。自动启用 --remote 选项。
CONTAINER_HOST¶ 容器主机
Set default --url
value to access Podman service. Automatically enables --remote option.
将默认 --url
值设置为访问 Podman 服务。自动启用 --remote 选项。
CONTAINER_SSHKEY¶ CONTAINER_SSHKEY
Set default --identity
path to ssh key file value used to access Podman service.
将默认 --identity
路径设置为用于访问 Podman 服务的 ssh 密钥文件值。
PODMAN_CONNECTIONS_CONF¶
PODMAN_CONNECTIONS_CONF
The path to the file where the system connections and farms created with podman system connection add
and podman farm add
are stored, by default it uses ~/.config/containers/podman-connections.json
.
存储系统连接和使用 podman system connection add
和 podman farm add
创建的存储池的文件路径,默认情况下使用 ~/.config/containers/podman-connections.json
。
STORAGE_DRIVER¶ 存储驱动程序
Set default --storage-driver
value. 设置默认 --storage-driver
值。
STORAGE_OPTS¶ 存储选项
Set default --storage-opts
value. 设置默认 --storage-opts
值。
TMPDIR¶ 临时目录 ¶
Set the temporary storage location of downloaded container images. Podman defaults to use /var/tmp
.
设置下载容器镜像的临时存储位置。Podman 默认使用 /var/tmp
。
XDG_CONFIG_HOME¶
In Rootless mode configuration files are read from XDG_CONFIG_HOME
when
specified, otherwise in the home directory of the user under
$HOME/.config/containers
.
在无根模式下,配置文件从指定时读取 XDG_CONFIG_HOME
,否则从 $HOME/.config/containers
用户的主目录中读取。
XDG_DATA_HOME¶
In Rootless mode images are pulled under XDG_DATA_HOME
when specified,
otherwise in the home directory of the user under
$HOME/.local/share/containers/storage
.
在无根模式下,镜像在指定时拉取到 XDG_DATA_HOME
,否则拉取到 $HOME/.local/share/containers/storage
用户的主目录中。
XDG_RUNTIME_DIR¶
In Rootless mode temporary configuration data is stored in ${XDG_RUNTIME_DIR}/containers
.
在无根模式下,临时配置数据存储在 ${XDG_RUNTIME_DIR}/containers
中。
Remote Access¶ 远程访问 ¶
The Podman command can be used with remote services using the --remote
flag. Connections can
be made using local unix domain sockets, ssh or directly to tcp sockets. When specifying the
podman --remote flag, only the global options --url
, --identity
, --log-level
, --connection
are used.
Podman 命令可以使用 --remote
标志与远程服务一起使用。可以使用本地 unix 域套接字、ssh 或直接连接到 tcp 套接字进行连接。在指定 podman --remote 标志时,仅使用全局选项 --url
, --identity
, --log-level
, --connection
。
Connection information can also be managed using the containers.conf file.
连接信息也可以使用 containers.conf 文件进行管理。
Exit Codes¶ 退出代码 ¶
The exit code from podman
gives information about why the container
failed to run or why it exited. When podman
commands exit with a non-zero code,
the exit codes follow the chroot
standard, see below:
从 podman
的退出代码提供了容器运行失败或退出的原因。当 podman
命令以非零代码退出时,退出代码遵循 chroot
标准,见下文:
125 The error is with podman itself
125 错误出现在 podman 本身
$ podman run --foo busybox; echo $?
Error: unknown flag: --foo
125
126 Executing a container command and the command cannot be invoked
126 执行容器命令时,命令无法调用。
$ podman run busybox /etc; echo $?
Error: container_linux.go:346: starting container process caused "exec: \"/etc\": permission denied": OCI runtime error
126
127 Executing a container command and the command cannot be found
127 执行容器命令,但找不到该命令
$ podman run busybox foo; echo $?
Error: container_linux.go:346: starting container process caused "exec: \"foo\": executable file not found in $PATH": OCI runtime error
127
Exit code otherwise, podman
returns the exit code of the container command
否则退出代码, podman
返回容器命令的退出代码
$ podman run busybox /bin/sh -c 'exit 3'; echo $?
3
COMMANDS¶ 命令 ¶
Command |
Description |
---|---|
Attach to a running container. |
|
Auto update containers according to their auto-update policy |
|
Build a container image using a Containerfile. |
|
Farm out builds to machines running podman for different architectures |
|
Create new image based on the changed container. |
|
Generate shell completion scripts |
|
Run Compose workloads via an external compose provider. |
|
Manage containers. 管理容器。 |
|
Copy files/folders between a container and the local filesystem. |
|
Create a new container. 创建一个新容器。 |
|
Inspect changes on a container or image’s filesystem. |
|
Monitor Podman events 监控 Podman 事件 |
|
Execute a command in a running container. |
|
Export a container’s filesystem contents as a tar archive. |
|
Generate structured data based on containers, pods or volumes. |
|
Manage healthchecks for containers |
|
Show the history of an image. |
|
Manage images. 管理镜像。 |
|
List images in local storage. |
|
Import a tarball and save it as a filesystem image. |
|
Display Podman related system information. |
|
Initialize one or more containers |
|
Display a container, image, volume, network, or pod’s configuration. |
|
Kill the main process in one or more containers. |
|
Load image(s) from a tar archive into container storage. |
|
Log in to a container registry. |
|
Log out of a container registry. |
|
Display the logs of one or more containers. |
|
Manage Podman’s virtual machine |
|
Create and manipulate manifest lists and image indexes. |
|
Mount a working container’s root filesystem. |
|
Manage Podman networks. 管理 Podman 网络。 |
|
Pause one or more containers. |
|
Play containers, pods or volumes based on a structured input file. |
|
Management tool for groups of containers, called pods. |
|
List port mappings for a container. |
|
Print out information about containers. |
|
Pull an image from a registry. |
|
Push an image, manifest list or image index from local storage to elsewhere. |
|
Rename an existing container. |
|
Restart one or more containers. |
|
Remove one or more containers. |
|
Remove one or more locally stored images. |
|
Run a command in a new container. |
|
Save image(s) to an archive. |
|
Search a registry for an image. |
|
Manage podman secrets. 管理 podman 机密。 |
|
Start one or more containers. |
|
Display a live stream of one or more container’s resource usage statistics. |
|
Stop one or more running containers. |
|
Manage podman. 管理 podman。 |
|
Add an additional name to a local image. |
|
Display the running processes of a container. |
|
Unmount a working container’s root filesystem. |
|
Unpause one or more containers. |
|
Run a command inside of a modified user namespace. |
|
Remove one or more names from a locally-stored image. |
|
Update the configuration of a given container. |
|
Display the Podman version information. |
|
Simple management tool for volumes. |
|
Wait on one or more containers to stop and print their exit codes. |
CONFIGURATION FILES¶ 配置文件
containers.conf (/usr/share/containers/containers.conf
, /etc/containers/containers.conf
, $HOME/.config/containers/containers.conf
)
Podman has builtin defaults for command line options. These defaults can be overridden using the containers.conf configuration files.
Podman 具有用于命令行选项的内置默认值。这些默认值可以通过 containers.conf 配置文件进行覆盖。
Distributions ship the /usr/share/containers/containers.conf
file with their default settings. Administrators can override fields in this file by creating the /etc/containers/containers.conf
file. Users can further modify defaults by creating the $HOME/.config/containers/containers.conf
file. Podman merges its builtin defaults with the specified fields from these files, if they exist. Fields specified in the users file override the administrator’s file, which overrides the distribution’s file, which override the built-in defaults.
发行版使用默认设置与其一起提供的 /usr/share/containers/containers.conf
文件。管理员可以通过创建 /etc/containers/containers.conf
文件来覆盖此文件中的字段。用户可以通过创建 $HOME/.config/containers/containers.conf
文件进一步修改默认设置。如果存在这些文件中指定的字段,Podman 会将其内置默认值与这些字段合并。用户文件中指定的字段会覆盖管理员文件,管理员文件会覆盖发行版文件,发行版文件会覆盖内置默认值。
Podman uses builtin defaults if no containers.conf file is found.
如果找不到 containers.conf 文件,Podman 将使用内置默认值。
If the CONTAINERS_CONF environment variable is set, then its value is used for the containers.conf file rather than the default.
如果设置了 CONTAINERS_CONF 环境变量,则其值将用于 containers.conf 文件,而不是默认值。
mounts.conf (/usr/share/containers/mounts.conf
)
The mounts.conf file specifies volume mount directories that are automatically mounted inside containers when executing the podman run
or podman start
commands. Administrators can override the defaults file by creating /etc/containers/mounts.conf
.
mounts.conf 文件指定了在执行 podman run
或 podman start
命令时自动挂载到容器内部的卷挂载目录。管理员可以通过创建 /etc/containers/mounts.conf
来覆盖默认文件。
When Podman runs in rootless mode, the file $HOME/.config/containers/mounts.conf
overrides the default if it exists. For details, see containers-mounts.conf(5).
当 Podman 在非 root 模式下运行时,如果存在文件 $HOME/.config/containers/mounts.conf
,则会覆盖默认设置。有关详细信息,请参阅 containers-mounts.conf(5)。
policy.json (/etc/containers/policy.json
) 策略.json ( /etc/containers/policy.json
)
Signature verification policy files are used to specify policy, e.g. trusted keys, applicable when deciding whether to accept an image, or individual signatures of that image, as valid.
签名验证策略文件用于指定策略,例如受信任的密钥,在决定是否接受图像或该图像的个别签名为有效时适用的策略。
registries.conf (/etc/containers/registries.conf
, $HOME/.config/containers/registries.conf
)
registries.conf is the configuration file which specifies which container registries is consulted when completing image names which do not include a registry or domain portion.
registries.conf 是配置文件,指定在完成不包括注册表或域部分的图像名称时要查询哪些容器注册表。
Non root users of Podman can create the $HOME/.config/containers/registries.conf
file to be used instead of the system defaults.
Podman 的非 root 用户可以创建 $HOME/.config/containers/registries.conf
文件,以替代系统默认文件。
If the CONTAINERS_REGISTRIES_CONF environment variable is set, then its value is used for the registries.conf file rather than the default.
如果设置了 CONTAINERS_REGISTRIES_CONF 环境变量,则其值将用于 registries.conf 文件,而不是默认值。
storage.conf (/etc/containers/storage.conf
, $HOME/.config/containers/storage.conf
)
storage.conf( /etc/containers/storage.conf
, $HOME/.config/containers/storage.conf
)
storage.conf is the storage configuration file for all tools using containers/storage
storage.conf 是所有使用容器/存储的工具的存储配置文件
The storage configuration file specifies all of the available container storage options for tools using shared container storage.
存储配置文件指定了所有可用的容器存储选项,适用于使用共享容器存储的工具
When Podman runs in rootless mode, the file $HOME/.config/containers/storage.conf
is used instead of the system defaults.
当 Podman 在非 root 模式下运行时,会使用文件 $HOME/.config/containers/storage.conf
而不是系统默认值。
If the CONTAINERS_STORAGE_CONF environment variable is set, then its value is used for the storage.conf file rather than the default.
如果设置了 CONTAINERS_STORAGE_CONF 环境变量,则其值将用于 storage.conf 文件,而不是默认值。
Rootless mode¶ 非 root 模式 ¶
Podman can also be used as non-root user. When podman runs in rootless mode, a user namespace is automatically created for the user, defined in /etc/subuid and /etc/subgid.
Podman 也可以作为非 root 用户使用。当 Podman 以无 root 模式运行时,会为用户自动创建用户命名空间,定义在 /etc/subuid 和 /etc/subgid 中。
Containers created by a non-root user are not visible to other users and are not seen or managed by Podman running as root.
非 root 用户创建的容器对其他用户不可见,并且不会被以 root 用户身份运行的 Podman 看到或管理。
It is required to have multiple UIDS/GIDS set for a user. Be sure the user is present in the files /etc/subuid
and /etc/subgid
.
用户需要为一个用户设置多个 UID/GID。确保用户存在于文件 /etc/subuid
和 /etc/subgid
中。
Execute the following commands to add the ranges to the files
执行以下命令将范围添加到文件中
$ sudo usermod --add-subuids 10000-75535 USERNAME
$ sudo usermod --add-subgids 10000-75535 USERNAME
Or just add the content manually.
或者手动添加内容。
$ echo USERNAME:10000:65536 >> /etc/subuid
$ echo USERNAME:10000:65536 >> /etc/subgid
See the subuid(5)
and subgid(5)
man pages for more information.
查看 subuid(5)
和 subgid(5)
手册获取更多信息。
Note: whitespace in any row of /etc/subuid or /etc/subgid, including trailing blanks, may result in no entry failures.
注意:/etc/subuid 或 /etc/subgid 中的任何行中的空格,包括尾随空格,可能导致没有条目失败。
Images are pulled under XDG_DATA_HOME
when specified, otherwise in the home directory of the user under .local/share/containers/storage
.
当指定时,图像将在 XDG_DATA_HOME
下拉取,否则将在 .local/share/containers/storage
用户的主目录下拉取。
Currently slirp4netns or pasta is required to be installed to create a network
device, otherwise rootless containers need to run in the network namespace of
the host.
目前需要安装 slirp4netns 或 pasta 才能创建网络设备,否则无根容器需要在主机的网络命名空间中运行。
In certain environments like HPC (High Performance Computing), users cannot take advantage of the additional UIDs and GIDs from the /etc/subuid and /etc/subgid systems. However, in this environment, rootless Podman can operate with a single UID. To make this work, set the ignore_chown_errors
option in the containers-storage.conf(5)
file. This option tells Podman when pulling an image to ignore chown errors when attempting to change a file in a container image to match the non-root UID in the image. This means all files get saved as the user’s UID. Note this can cause issues when running the container.
在某些环境中,比如 HPC(高性能计算),用户无法利用 /etc/subuid 和 /etc/subgid 系统中的额外 UID 和 GID。然而,在这种环境中,无根 Podman 可以使用单个 UID 运行。为了使其正常工作,请在 containers-storage.conf(5)
文件中设置 ignore_chown_errors
选项。该选项告诉 Podman 在拉取镜像时忽略 chown 错误,当尝试更改容器镜像中的文件以匹配镜像中的非 root UID 时。这意味着所有文件都将保存为用户的 UID。请注意,这可能会在运行容器时引发问题。
NOTE: Unsupported file systems in rootless mode¶
注意:无根模式下不支持的文件系统 ¶
The Overlay file system (OverlayFS) is not supported with kernels prior to 5.12.9 in rootless mode. The fuse-overlayfs package is a tool that provides the functionality of OverlayFS in user namespace that allows mounting file systems in rootless environments. It is recommended to install the fuse-overlayfs package. In rootless mode, Podman automatically uses the fuse-overlayfs program as the mount_program if installed, as long as the $HOME/.config/containers/storage.conf file was not previously created. If storage.conf exists in the homedir, add mount_program = "/usr/bin/fuse-overlayfs"
under [storage.options.overlay]
to enable this feature.
Overlay 文件系统(OverlayFS)在内核版本低于 5.12.9 时不支持 rootless 模式。fuse-overlayfs 软件包是一个工具,提供了在用户命名空间中使用 OverlayFS 的功能,允许在 rootless 环境中挂载文件系统。建议安装 fuse-overlayfs 软件包。在 rootless 模式下,如果安装了 fuse-overlayfs 程序,Podman 将自动将其用作 mount_program,只要 $HOME/.config/containers/storage.conf 文件之前未创建。如果 storage.conf 存在于主目录中,请在 [storage.options.overlay]
下添加 mount_program = "/usr/bin/fuse-overlayfs"
以启用此功能。
The Network File System (NFS) and other distributed file systems (for example: Lustre, Spectrum Scale, the General Parallel File System (GPFS)) are not supported when running in rootless mode as these file systems do not understand user namespace. However, rootless Podman can make use of an NFS Homedir by modifying the $HOME/.config/containers/storage.conf
to have the graphroot
option point to a directory stored on local (Non NFS) storage.
网络文件系统(NFS)和其他分布式文件系统(例如:Lustre、Spectrum Scale、通用并行文件系统(GPFS))在 rootless 模式下运行时不受支持,因为这些文件系统不理解用户命名空间。但是,rootless Podman 可以通过修改 $HOME/.config/containers/storage.conf
使 NFS Homedir 生效,将 graphroot
选项指向存储在本地(非 NFS)存储上的目录。
For more information, see the Podman Troubleshooting Page.
更多信息,请参阅 Podman 故障排除页面。
SEE ALSO¶ 参见 ¶
containers-mounts.conf(5), containers.conf(5), containers-registries.conf(5), containers-storage.conf(5), buildah(1), oci-hooks(5), containers-policy.json(5), crun(1), runc(8), subuid(5), subgid(5), slirp4netns(1), pasta(1), conmon(8)
HISTORY¶ 历史 ¶
Dec 2016, Originally compiled by Dan Walsh dwalsh@redhat.com
2016 年 12 月,最初由 Dan Walsh dwalsh@redhat.com 编译