在 Podman 中,可以使用 podman search 命令从配置的镜像仓库(默认通常为 Docker Hub)中检索镜像,它能根据你指定的关键词,遍历仓库中的镜像元数据,返回包含镜像名称、描述、星级、是否官方 / 自动构建等信息的搜索结果,帮助你快速定位所需镜像。
下面是 podman search 命令的基础语法:
podman search [选项] <搜索关键词>
常用选项:
-f, --filter 根据条件过滤搜索结果,例如:podman search --filter is-official=true nginx
--limit 限制返回结果的数量(默认 25),例如:podman search --limit 10 nginx
--no-trunc 不截断输出结果(显示完整描述),例如:podman search --no-trunc alpine
--list-tags 列出镜像的标签,例如:podman search --list-tags nginx
点击查看 podman search 命令手册。
注意,由于网络原因,这里将临时指定 docker.1ms.run 毫秒镜像进行搜索。
最简单的用法,根据关键词查找所有相关镜像:
# 搜索包含 "nginx" 关键词的所有镜像 podman search nginx # 搜索包含 "python" 关键词的所有镜像 podman search python
例如:
C:\Users\Administrator> podman search docker.1ms.run/library/nginx NAME DESCRIPTION docker.1ms.run/nginx Official build of Nginx. docker.1ms.run/nginx/nginx-ingress NGINX and NGINX Plus Ingress Controllers fo... docker.1ms.run/nginx/nginx-prometheus-exporter NGINX Prometheus Exporter for NGINX and NGIN... docker.1ms.run/nginx/unit This repository is retired, use the Docker o... docker.1ms.run/nginx/nginx-ingress-operator NGINX Ingress Operator for NGINX and NGINX P... docker.1ms.run/nginx/docker-extension docker.1ms.run/nginx/nginx-quic-qns NGINX QUIC interop docker.1ms.run/nginx/nginxaas-loadbalancer-kubernetes
使用过滤器查找官方认证的镜像(更可靠、安全):
# 只显示官方的 nginx 镜像 podman search --filter is-official=true nginx # 只显示官方的 alpine 镜像 podman search --filter is-official=true alpine
例如:
C:\Users\Administrator> podman search --filter is-official=true docker.1ms.run/library/nginx NAME DESCRIPTION docker.1ms.run/nginx Official build of Nginx.
筛选星级较高的镜像(社区认可度更高):
# 搜索星级大于等于 100 的 redis 镜像 podman search --filter stars=100 redis # 搜索星级大于等于 50 的 ubuntu 镜像 podman search --filter stars=50 ubuntu
例如:
C:\Users\Administrator> podman search --filter stars=50 docker.1ms.run/library/ubuntu NAME DESCRIPTION docker.1ms.run/ubuntu Ubuntu is a Debian-based Linux operating sys... docker.1ms.run/ubuntu/squid Squid is a caching proxy for the Web. Long-t... docker.1ms.run/ubuntu/nginx Nginx, a high-performance reverse proxy & we... docker.1ms.run/ubuntu/bind9 BIND 9 is a very flexible, full-featured DNS... docker.1ms.run/ubuntu/kafka Apache Kafka, a distributed event streaming... docker.1ms.run/ubuntu/apache2 Apache, a secure & extensible open-source HT... docker.1ms.run/ubuntu/prometheus Prometheus is a systems and service monitori... docker.1ms.run/ubuntu/mysql MySQL open source fast, stable, multi-thread...
查看特定镜像的可用版本标签:
# 列出官方 nginx 镜像的所有标签 podman search --list-tags nginx # 列出官方 centos 镜像的所有标签 podman search --list-tags centos
例如:
C:\Users\Administrator> podman search --list-tags docker.1ms.run/library/nginx NAME TAG docker.1ms.run/library/nginx 1 docker.1ms.run/library/nginx 1-alpine docker.1ms.run/library/nginx 1-alpine-otel docker.1ms.run/library/nginx 1-alpine-perl docker.1ms.run/library/nginx 1-alpine-slim docker.1ms.run/library/nginx 1-alpine3.17 docker.1ms.run/library/nginx 1-alpine3.17-perl docker.1ms.run/library/nginx 1-alpine3.17-slim docker.1ms.run/library/nginx 1-alpine3.18 ...
当结果太多时,限制返回数量:
# 只返回前 5 个包含 "mysql" 的镜像 podman search --limit 5 mysql # 只返回前 10 个官方的 node 镜像 podman search --filter is-official=true --limit 10 node
例如:
C:\Users\Administrator> podman search --limit 5 docker.1ms.run/library/mysql NAME DESCRIPTION docker.1ms.run/mysql MySQL is a widely used, open-source relation... docker.1ms.run/bitnami/mysql Bitnami Secure Image for mysql docker.1ms.run/circleci/mysql MySQL is a widely used, open-source relation... docker.1ms.run/bitnamicharts/mysql Bitnami Helm chart for MySQL docker.1ms.run/cimg/mysql C:\Users\Administrator> podman search docker.1ms.run/library/mysql NAME DESCRIPTION docker.1ms.run/mysql MySQL is a widely used, open-source relation... docker.1ms.run/bitnami/mysql Bitnami Secure Image for mysql docker.1ms.run/circleci/mysql MySQL is a widely used, open-source relation... docker.1ms.run/bitnamicharts/mysql Bitnami Helm chart for MySQL docker.1ms.run/cimg/mysql docker.1ms.run/ubuntu/mysql MySQL open source fast, stable, multi-thread... docker.1ms.run/google/mysql MySQL server for Google Compute Engine docker.1ms.run/linuxserver/mysql A Mysql container, brought to you by LinuxSe... docker.1ms.run/elestio/mysql Mysql, verified and packaged by Elestio docker.1ms.run/docksal/mysql MySQL service images for Docksal - https://d... docker.1ms.run/alpine/mysql mysql client docker.1ms.run/eclipse/mysql Mysql 5.7, curl, rsync docker.1ms.run/datajoint/mysql MySQL image pre-configured to work smoothly... docker.1ms.run/ilios/mysql Mysql configured for running Ilios docker.1ms.run/ddev/mysql ARM64 base images for ddev-dbserver-mysql-8.... docker.1ms.run/mirantis/mysql docker.1ms.run/mysql/mysql-server Optimized MySQL Server Docker images. Create... docker.1ms.run/corpusops/mysql https://github.com/corpusops/docker-images/ docker.1ms.run/vulhub/mysql docker.1ms.run/cbioportal/mysql This repository hosts MySQL database images... docker.1ms.run/vitess/mysql Lightweight image to run MySQL with Vitess docker.1ms.run/mysql/mysql-router MySQL Router provides transparent routing be... docker.1ms.run/mysql/mysql-cluster Experimental MySQL Cluster Docker images. Cr... docker.1ms.run/nasqueron/mysql docker.1ms.run/mysql/mysql-operator MySQL Operator for Kubernetes
默认输出会截断长描述,使用 --no-trunc 查看完整信息:
# 查看 nginx 镜像的完整描述 podman search --no-trunc nginx # 查看官方 alpine 镜像的完整描述 podman search --filter is-official=true --no-trunc alpine
例如:
:\Users\Administrator> podman search --no-trunc docker.1ms.run/library/nginx NAME DESCRIPTION docker.1ms.run/nginx Official build of Nginx. docker.1ms.run/nginx/nginx-ingress NGINX and NGINX Plus Ingress Controllers for Kubernetes docker.1ms.run/nginx/nginx-prometheus-exporter NGINX Prometheus Exporter for NGINX and NGINX Plus docker.1ms.run/nginx/unit This repository is retired, use the Docker official images: https://hub.docker.com/_/unit docker.1ms.run/nginx/nginx-ingress-operator NGINX Ingress Operator for NGINX and NGINX Plus Ingress Controllers. Based on the Helm chart for NGI docker.1ms.run/nginx/docker-extension docker.1ms.run/nginx/nginx-quic-qns NGINX QUIC interop ...
同时使用多个过滤条件进行精确查找:
# 查找官方且星级 >= 50 的 postgres 镜像 podman search --filter is-official=true --filter stars=50 postgres # 查找自动构建且星级 >= 10 的 docker 镜像 podman search --filter is-automated=true --filter stars=10 docker
例如:
C:\Users\Administrator> podman search --filter is-automated=true --filter stars=10 docker.1ms.run/library/nginx NAME DESCRIPTION docker.1ms.run/bitnami/nginx Bitnami Secure Image for nginx
结合关键词搜索特定发行版的镜像:
# 搜索 ubuntu 22.04 相关镜像 podman search ubuntu:22.04 # 搜索基于 alpine 的 python 镜像 podman search python alpine
例如:
C:\Users\Administrator> podman search docker.1ms.run/library/ubuntu:22.04 NAME DESCRIPTION docker.1ms.run/ubuntu Ubuntu is a Debian-based Linux operating sys... docker.1ms.run/ubuntu/squid Squid is a caching proxy for the Web. Long-t... docker.1ms.run/ubuntu/nginx Nginx, a high-performance reverse proxy & we... docker.1ms.run/ubuntu/cortex Cortex provides storage for Prometheus. Long... docker.1ms.run/ubuntu/bind9 BIND 9 is a very flexible, full-featured DNS... docker.1ms.run/ubuntu/kafka Apache Kafka, a distributed event streaming... docker.1ms.run/ubuntu/apache2 Apache, a secure & extensible open-source HT... docker.1ms.run/ubuntu/prometheus Prometheus is a systems and service monitori... docker.1ms.run/ubuntu/zookeeper ZooKeeper maintains configuration informatio... docker.1ms.run/ubuntu/mysql MySQL open source fast, stable, multi-thread... docker.1ms.run/ubuntu/jre Chiseled Java runtime based on Ubuntu. Long-... docker.1ms.run/ubuntu/postgres PostgreSQL is an open source object-relation... docker.1ms.run/ubuntu/dotnet-aspnet Chiselled Ubuntu runtime image for ASP.NET a.. ...
更多信息请参考官方文档。