在 Podman 中,可以使用 podman pull 命令从远程镜像仓库拉取镜像到本地,语法和使用方式与 Docker 的 docker pull 类似。
podman pull [选项] 镜像名称[:标签|@摘要]
选项说明:
-a, --all-tags 拉取该镜像的所有标签版本(谨慎使用,可能占用大量存储空间)。
--platform 指定拉取镜像的目标平台(如 linux/amd64、linux/arm64),适用于跨架构场景。示例:podman pull --platform linux/arm64 nginx
--tls-verify 控制是否验证仓库的 TLS 证书(默认 true)。私有仓库若证书不被信任,可设为 false(不推荐,有安全风险)。示例:podman pull --tls-verify=false myregistry.com/app
-q, --quiet 静默模式,仅输出拉取成功后的镜像 ID,不显示进度信息。
--creds 指定仓库的认证信息(用户名:密码),用于拉取私有镜像。示例:podman pull --creds user:pass myregistry.com/app
点击查看 podman pull 命令手册。
若不指定标签,默认拉取 latest 标签的镜像:
podman pull nginx # 两者完全等价 podman pull nginx:latest
例如:
C:\Users\hxstri> podman pull nginx Resolving "nginx" using unqualified-search registries (/home/user/.config/containers/registries.conf) Trying to pull docker.io/library/nginx:latest... Getting image source signatures Copying blob sha256:192e2451f8751fb74549c932e26a9bcfd7b669fe2f5bd8381ea5ac65f09b256b Copying blob sha256:b5feb73171bf1bcf29fdd1ba642c3d30cdf4c6329b19d89be14d209d778c89ba Copying blob sha256:77fa2eb0631772679b0e48eca04f4906fba5fe94377e01618873a4a1171107ce Copying blob sha256:0e4bc2bd6656e6e004e3c749af70e5650bac2258243eb0949dea51cb8b7863db Copying blob sha256:108ab82928207dabd9abfddbc960dd842364037563fc560b8f6304e4a91454fe Copying blob sha256:53d743880af45adf9f141eec1fe3a413087e528075a5d8884d6215ddfdd2b806 Copying blob sha256:de57a609c9d5148f10b38f5c920d276e9e38b2856fe16c0aae1450613dc12051 Copying config sha256:60adc2e137e757418d4d771822fa3b3f5d3b4ad58ef2385d200c9ee78375b6d5 Writing manifest to image destination 60adc2e137e757418d4d771822fa3b3f5d3b4ad58ef2385d200c9ee78375b6d5 C:\Users\hxstri> podman images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/library/nginx latest 60adc2e137e7 22 hours ago 155 MB
使用 podman pull nginx:latest 拉去镜像:
C:\Users\hxstri> podman pull nginx:latest Resolving "nginx" using unqualified-search registries (/home/user/.config/containers/registries.conf) Trying to pull docker.io/library/nginx:latest... Getting image source signatures Copying blob sha256:192e2451f8751fb74549c932e26a9bcfd7b669fe2f5bd8381ea5ac65f09b256b Copying blob sha256:b5feb73171bf1bcf29fdd1ba642c3d30cdf4c6329b19d89be14d209d778c89ba Copying blob sha256:108ab82928207dabd9abfddbc960dd842364037563fc560b8f6304e4a91454fe Copying blob sha256:0e4bc2bd6656e6e004e3c749af70e5650bac2258243eb0949dea51cb8b7863db Copying blob sha256:53d743880af45adf9f141eec1fe3a413087e528075a5d8884d6215ddfdd2b806 Copying blob sha256:77fa2eb0631772679b0e48eca04f4906fba5fe94377e01618873a4a1171107ce Copying blob sha256:de57a609c9d5148f10b38f5c920d276e9e38b2856fe16c0aae1450613dc12051 Copying config sha256:60adc2e137e757418d4d771822fa3b3f5d3b4ad58ef2385d200c9ee78375b6d5 Writing manifest to image destination 60adc2e137e757418d4d771822fa3b3f5d3b4ad58ef2385d200c9ee78375b6d5 C:\Users\hxstri> podman images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/library/nginx latest 60adc2e137e7 22 hours ago 155 MB
通过 :标签 指定具体版本:
podman pull ubuntu:22.04 # 拉取 Ubuntu 22.04 版本
例如:
C:\Users\hxstri> podman pull ubuntu:22.04 Resolving "ubuntu" using unqualified-search registries (/home/user/.config/containers/registries.conf) Trying to pull docker.io/library/ubuntu:22.04... Getting image source signatures Copying blob sha256:7e49dc6156b0b532730614d83a65ae5e7ce61e966b0498703d333b4d03505e4f Copying config sha256:9fa3e2b5204f4fd5ae0d53dee5c367ac686a8a39685d9261b9d3d3c8a9cc8917 Writing manifest to image destination 9fa3e2b5204f4fd5ae0d53dee5c367ac686a8a39685d9261b9d3d3c8a9cc8917 C:\Users\hxstri> podman images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/library/ubuntu 22.04 9fa3e2b5204f 5 weeks ago 80.4 MB
如果镜像不在默认仓库(如 Docker Hub),需指定完整仓库路径:
podman pull quay.io/podman/stable # 从 Quay.io 拉取 Podman 稳定版镜像
例如:
C:\Users\hxstri> podman pull quay.io/podman/stable Trying to pull quay.io/podman/stable:latest... Getting image source signatures Copying blob sha256:af668a1af636134f8152173118c1c95a0af4b5f0570d90bf70f66a0d1028f2ee Copying blob sha256:5c65b689382b5c12cc77d1b0967608a0b240e7ab5e3ab70dd071c58acd499041 Copying blob sha256:8c0072cf5631a2669792ec2ff34df8b657935a32180b5e81a62d5785b8ce29fe Copying blob sha256:fc1ac6080e1b0716fe5708f19d9120c390bd7da81e08060fa74d8bc7d2dbbcf5 Copying blob sha256:b1753d05b8b94584f7896bd0c0cf85e71437dab00e550cab5b7f9742dfe1e993 Copying blob sha256:e2b4c9e1c0c803f69241de8b71ceac6333bef7f641f55c4dbab321f159637bb1 Copying blob sha256:75c72edb91e2bb1616aedfdfcc179c2acfd55e3adfc16e4559f66a75042d7301 Copying blob sha256:a67a9b72b0ab1427fa8a26a8cdf839a51c98233dd81791c3e4e760191f11d5eb Copying blob sha256:5c7e4334728facf42d908d12db027be715bf68b845539517aacac114deb0b5b5 Copying blob sha256:1846cb416a78e949aa195d711160c58bbdbe5b750c547d9a49c8d4b383be9745 Copying config sha256:86657be16bc1e8d9fbe22edadaa15fb14e67e85789eb24b0b6011d6c55110e8c Writing manifest to image destination 86657be16bc1e8d9fbe22edadaa15fb14e67e85789eb24b0b6011d6c55110e8c C:\Users\hxstri> podman images REPOSITORY TAG IMAGE ID CREATED SIZE quay.io/podman/stable latest 86657be16bc1 11 hours ago 567 MB
镜像摘要(Digest)是唯一标识,可精确拉取特定版本(避免标签被覆盖的问题)。
podman pull nginx@sha256:abc123... # 替换为实际的镜像摘要
例如:
首先需要知道目标镜像的具体摘要(通常是 sha256 开头的哈希值)。可以通过以下方式获取:
查看远程仓库的镜像详情(如 Docker Hub 网页上的镜像 “Digest” 信息)。
本地已拉取镜像时,通过 podman images --digests 查看:
C:\Users\hxstri> podman images --digests REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE docker.io/library/nginx latest sha256:553f64aecdc31b5bf944521731cd70e35da4faed96b2b7548a3d8e2598c52a42 60adc2e137e7 22 hours ago 155 MB
上面输出中,sha256:553f64aecdc31b5bf944521731cd70e35da4faed96b2b7548a3d8e2598c52a42 就是镜像摘要。
C:\Users\hxstri> podman pull nginx@sha256:553f64aecdc31b5bf944521731cd70e35da4faed96b2b7548a3d8e2598c52a42 Resolving "nginx" using unqualified-search registries (/home/user/.config/containers/registries.conf) Trying to pull docker.io/library/nginx@sha256:553f64aecdc31b5bf944521731cd70e35da4faed96b2b7548a3d8e2598c52a42... Getting image source signatures Copying blob sha256:192e2451f8751fb74549c932e26a9bcfd7b669fe2f5bd8381ea5ac65f09b256b Copying blob sha256:b5feb73171bf1bcf29fdd1ba642c3d30cdf4c6329b19d89be14d209d778c89ba Copying blob sha256:0e4bc2bd6656e6e004e3c749af70e5650bac2258243eb0949dea51cb8b7863db Copying blob sha256:53d743880af45adf9f141eec1fe3a413087e528075a5d8884d6215ddfdd2b806 Copying blob sha256:108ab82928207dabd9abfddbc960dd842364037563fc560b8f6304e4a91454fe Copying blob sha256:77fa2eb0631772679b0e48eca04f4906fba5fe94377e01618873a4a1171107ce Copying blob sha256:de57a609c9d5148f10b38f5c920d276e9e38b2856fe16c0aae1450613dc12051 Copying config sha256:60adc2e137e757418d4d771822fa3b3f5d3b4ad58ef2385d200c9ee78375b6d5 Writing manifest to image destination 60adc2e137e757418d4d771822fa3b3f5d3b4ad58ef2385d200c9ee78375b6d5 C:\Users\hxstri> podman images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/library/nginx <none> 60adc2e137e7 22 hours ago 155 MB
使用 --tls-verify 选项,拉取过程不验证仓库的 TLS 证书。
C:\Users\hxstri> podman pull --tls-verify=false mysql Resolving "mysql" using unqualified-search registries (/home/user/.config/containers/registries.conf) Trying to pull docker.io/library/mysql:latest... Getting image source signatures Copying blob sha256:834e15e3ed24cc4f9aca80d06d9e1c326fdf2d6c9010aec6ade4a5b6adcb0909 Copying blob sha256:023a182c62a0ce5adf24030e7fee994ceaa333b22cdb5f1a0835501015edf3ed Copying blob sha256:f5f78fcd9ccb610500632aecc1bfe9e99e435e59db4bbc4bbbcd3d88c42cc978 Copying blob sha256:494c372d15c3b92efb09997030051878646d920a87c1b3fbe0cd97db2035b923 Copying blob sha256:dcee80f7340cccc4aa006efed1341c559a2208d5aa56ca63333c693e0e4f626c Copying blob sha256:480d01bd7a6a054f0991aaa1cb36f2c5c0ddbc31a3a745501d6de0969d1095f0 Copying blob sha256:c276de9b557163ac7f4e24ada733affb7896174f8bc5a53bd45585ec6dfae78f Copying blob sha256:0cd145fbb4492429860f19b1c488cfd5e7b3917ea74516712e292e9d752b481f Copying blob sha256:5a3f7744d0e71a4f56974497ec5607084830ecccc031503a866c71ec5dcbc1d7 Copying blob sha256:21aa606d8d58de0a0d2990e09dfe17f14ee464e557af363532ea90a49a685182 Copying config sha256:f6b0ca07d79d7d19c8da64558c3ccdd4ea635ac2193f551a1cb5370f33b494e8 Writing manifest to image destination f6b0ca07d79d7d19c8da64558c3ccdd4ea635ac2193f551a1cb5370f33b494e8
更多知识请参考官方文档。