名称

podman-push - 将本地存储中的镜像、清单列表或镜像索引推送到其他位置

简介

podman push [选项] 镜像 [目标]

podman image push [选项] 镜像 [目标]

描述

将本地存储中的镜像、清单列表或镜像索引推送到指定的目标。

镜像存储

镜像是从本地镜像存储中推送的。

目标

目标(DESTINATION)是容器镜像被推送到的位置。它支持 containers-transports(5) 中的所有传输方式。如果未指定传输方式,则使用 docker(即容器注册中心)传输方式。对于远程客户端,包括 Mac 和 Windows(不含 WSL2)机器,docker 是唯一支持的传输方式。

# Push to a container registry
$ podman push quay.io/podman/stable

# Push to a container registry via the docker transport
$ podman push docker://quay.io/podman/stable

# Push to a container registry with another tag
$ podman push myimage quay.io/username/myimage

# Push to a local directory
$ podman push myimage dir:/tmp/myimage

# Push to a tarball in the docker-archive format
$ podman push myimage docker-archive:/tmp/myimage

# Push to a local docker daemon
$ sudo podman push myimage docker-daemon:docker.io/library/myimage:33

# Push to a tarball in the OCI format
$ podman push myimage oci-archive:/tmp/myimage

选项

--authfile=path

认证文件的路径。在 Linux 上默认为 ${XDG_RUNTIME_DIR}/containers/auth.json,在 Windows/macOS 上默认为 $HOME/.config/containers/auth.json。该文件由 podman login 创建。如果在此处找不到授权状态,则会检查 $HOME/.docker/config.json,该文件由 docker login 设置。

注意:也可以通过设置 REGISTRY_AUTH_FILE 环境变量来覆盖认证文件的默认路径。这可以通过 export REGISTRY_AUTH_FILE=路径 来完成。

--cert-dir=path

使用位于 path 的证书(*.crt, *.cert, *.key)连接到注册中心。(默认值:/etc/containers/certs.d)详情请参阅 containers-certs.d(5)。(此选项不适用于远程 Podman 客户端,包括 Mac 和 Windows(不含 WSL2)机器)

--compress

当使用 'dir' 传输方式推送到目录时,压缩 tarball 镜像层。(默认使用与源相同的压缩类型,压缩或未压缩)

注意:此标志只能在与 dir 传输方式一起使用时设置

--compression-format=gzip | zstd | zstd:chunked

指定要使用的压缩格式。支持的值为:gzipzstdzstd:chunked。默认值为 gzip,除非在 containers.conf 文件中被覆盖。zstd:chunked 与加密镜像不兼容,在这种情况下它将被视为 zstd 并显示警告。

--compression-level=level

指定要使用的压缩级别。该值特定于所使用的压缩算法,例如对于 zstd,可接受的值范围是 1-20(含),默认值为 3;而对于 gzip,范围是 1-9(含),默认值为 5。

--creds=[username[:password]]

用于向镜像仓库进行身份验证的 [username[:password]](如果需要)。如果未提供一个或两个值,则会出现命令行提示,可以输入该值。密码输入时无回显。

请注意,指定的凭据仅用于对目标注册中心进行身份验证。它们不用于镜像源或当注册中心被重写时(请参阅 containers-registries.conf(5));要对这些进行身份验证,请考虑使用 containers-auth.json(5) 文件。

--digestfile=Digestfile

复制镜像后,将生成镜像的摘要写入该文件。

--disable-content-trust

这是一个 Docker 特定的选项,用于禁用对容器仓库的镜像验证,Podman 不支持此选项。此选项是一个空操作(NOOP),仅为脚本兼容性而提供。

--encrypt-layer=layer(s)

要加密的层:0-索引的层索引,支持负索引(例如,0 是第一层,-1 是最后一层)。如果未定义,且指定了 encryption-key 标志,则加密所有层。

--encryption-key=key

[protocol:keyfile] 指定了加密协议,可以是 JWE (RFC7516)、PGP (RFC4880) 和 PKCS7 (RFC2315),以及镜像加密所需的密钥材料。例如,jwe:/path/to/key.pem 或 pgp:admin@example.com 或 pkcs7:/path/to/x509-file。

--force-compression

如果设置此项,即使目标已包含不同压缩方式的变体,推送操作也会使用指定的压缩算法。如果命令行上明确指定了 --compression-format,则默认为 true,否则为 false

--format, -f=format

推送镜像时使用的清单类型(oci、v2s2 或 v2s1)。

--quiet, -q

写入输出镜像时,禁止显示进度输出

--remove-signatures

丢弃镜像中任何预先存在的签名。

--retry=attempts

在仓库和本地存储之间拉取或推送镜像失败时重试的次数。默认为 3

--retry-delay=duration

在注册中心和本地存储之间拉取或推送镜像失败时,重试尝试之间的延迟时间。默认是从两秒开始,然后指数级退避。如果设置了此值,则使用该延迟时间,并且不会发生指数级退避。

--sign-by=key

使用指定的密钥在目标位置添加一个“简单签名”的签名。(此选项不适用于远程 Podman 客户端,包括 Mac 和 Windows(不含 WSL2)机器)

--sign-by-sigstore=param-file

根据容器的 sigstore 签名参数文件 param-file 中指定的进一步选项添加一个 sigstore 签名。有关文件格式的详细信息,请参阅 containers-sigstore-signing-params.yaml(5)。

--sign-by-sigstore-private-key=path

使用指定路径的私钥在目标位置添加一个 sigstore 签名。(此选项不适用于远程 Podman 客户端,包括 Mac 和 Windows(不含 WSL2)机器)

--sign-passphrase-file=path

如果对镜像进行签名(使用 --sign-by--sign-by-sigstore-private-key),则从指定路径读取要使用的密码短语。

--tls-verify

在联系注册中心时要求 HTTPS 并验证证书(默认值:true)。如果明确设置为 true,则使用 TLS 验证。如果设置为 false,则不使用 TLS 验证。如果未指定,则使用 TLS 验证,除非目标注册中心在 containers-registries.conf(5) 中被列为不安全的注册中心。

示例

将指定的镜像推送到本地目录

# podman push imageID dir:/path/to/image

将指定的镜像以 OCI 格式推送到本地目录

# podman push imageID oci-archive:/path/to/layout:image:tag

将指定的镜像推送到容器注册中心

# podman push imageID docker://registry.example.com/repository:tag

将指定的镜像推送到容器注册中心,并将摘要保存在指定的文件中

# podman push --digestfile=/tmp/mydigest imageID docker://registry.example.com/repository:tag

将指定的镜像推送到本地 Docker 守护进程的容器存储中

# podman push imageID docker-daemon:image:tag

使用备用 authfile 路径中的凭据,以不同的镜像名称推送指定的镜像

# podman push --authfile temp-auths/myauths.json alpine docker://docker.io/umohnani/alpine
Getting image source signatures
Copying blob sha256:5bef08742407efd622d243692b79ba0055383bbce12900324f75e56f589aedb0
 4.03 MB / 4.03 MB [========================================================] 1s
Copying config sha256:ad4686094d8f0186ec8249fc4917b71faa2c1030d7b5a025c29f26e19d95c156
 1.41 KB / 1.41 KB [========================================================] 1s
Writing manifest to image destination
Storing signatures

将指定的镜像作为 OCI 镜像推送到本地目录

# podman push --format oci registry.access.redhat.com/rhel7 dir:rhel7-dir
Getting image source signatures
Copying blob sha256:9cadd93b16ff2a0c51ac967ea2abfadfac50cfa3af8b5bf983d89b8f8647f3e4
 71.41 MB / 71.41 MB [======================================================] 9s
Copying blob sha256:4aa565ad8b7a87248163ce7dba1dd3894821aac97e846b932ff6b8ef9a8a508a
 1.21 KB / 1.21 KB [========================================================] 0s
Copying config sha256:f1b09a81455c351eaa484b61aacd048ab613c08e4c5d1da80c4c46301b03cf3b
 3.01 KB / 3.01 KB [========================================================] 0s
Writing manifest to image destination
Storing signatures

另请参阅

podman(1), podman-pull(1), podman-login(1), containers-certs.d(5), containers-registries.conf(5), containers-transports(5)

故障排除

有关常见问题的解决方案,请参阅 podman-troubleshooting(7)