18.4. 将容器镜像复制到主机或从主机复制
Skopeo、Buildah 和 Podman 共享相同的本地容器镜像存储。如果要将容器复制到主机容器存储或从主机容器存储中复制,则需要将其挂载到 Skopeo 容器中。
注意
到主机容器存储的路径在 root 用户(/var/lib/containers/storage
)和非 root 用户($HOME/.local/share/containers/storage
)之间有所不同。
先决条件
-
container-tools
元数据包已安装。
流程
将
registry.access.redhat.com/ubi9/ubi
镜像复制到本地容器存储中:$ podman run --privileged --rm -v $HOME/.local/share/containers/storage:/var/lib/containers/storage \ registry.redhat.io/rhel9/skopeo skopeo copy \ docker://registry.access.redhat.com/ubi9/ubi containers-storage:registry.access.redhat.com/ubi9/ubi
-
privileged
选项禁用所有安全机制。红帽建议仅在可信环境中使用这个选项。 为了避免禁用安全机制,请将镜像导出到 tarball 或其它基于路径的镜像传输,并将其挂载到 Skopeo 容器中:
-
$ podman save --format oci-archive -o oci.tar $IMAGE
-
$ podman run --rm -v oci.tar:/oci.tar registry.redhat.io/rhel9/skopeo copy oci-archive:/oci.tar $DESTINATION
-
-
可选:列出本地存储中的镜像:
$ podman images REPOSITORY TAG IMAGE ID CREATED SIZE registry.access.redhat.com/ubi9/ubi latest ecbc6f53bba0 8 weeks ago 211 MB
其他资源