Skip to content

Command Search

从 Docker Hub 查找(搜索)镜像

一. 基本应用

语法:docker search [OPTIONS] TERM

【示例一】搜索镜像名称中包含 java 相关的所有镜像

$ docker search java
NAME                                 DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
node                                 Node.js is a JavaScript-based platform for s…   11948     [OK]       
tomcat                               Apache Tomcat is an open source implementati…   3399      [OK]       
java                                 DEPRECATED; use "openjdk" (or other JDK impl…   1976      [OK]       
ghost                                Ghost is a free and open source blogging pla…   1557      [OK]       
couchdb                              CouchDB is a database that uses JSON for doc…   487       [OK]       
jetty                                Jetty provides a Web server and javax.servle…   385       [OK]       
amazoncorretto                       Corretto is a no-cost, production-ready dist…   242       [OK]       
groovy                               Apache Groovy is a multi-faceted language fo…   135       [OK]       
circleci/node                        Node.js is a JavaScript-based platform for s…   129                  
ibmjava                              Official IBM® SDK, Java™ Technology Edition    103       [OK]       
tomee                                Apache TomEE is an all-Apache Java EE certif…   98        [OK]       
ibmcom/ibmjava                       IBM® SDK, Java™ Technology Edition Docker Im…   20                   
bitnami/java                         Bitnami Java Docker Image                       10                   [OK]

列表说明

  • NAME:镜像名称(镜像仓库源的名称)
  • DESCRIPTION:该镜像的描述说明
  • STARS:表示点赞、欢迎的点击数
  • OFFICIAL:是否为 Docker 官方发布
  • AUTOMATED:是否自动构建

【示例二】搜索 java 相关的前 5 个镜像

1
2
3
4
5
6
7
$ docker search java --limit 5
NAME      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
node      Node.js is a JavaScript-based platform for s…   11948     [OK]       
tomcat    Apache Tomcat is an open source implementati…   3399      [OK]       
java      DEPRECATED; use "openjdk" (or other JDK impl…   1976      [OK]       
ghost     Ghost is a free and open source blogging pla…   1557      [OK]       
couchdb   CouchDB is a database that uses JSON for doc…   487       [OK] 

【示例三】只搜索自动构建的镜像,AUTOMATED 为 [OK] 的

1
2
3
4
$ docker search -f is-automated=true java
NAME                                 DESCRIPTION                                 STARS     OFFICIAL   AUTOMATED
bitnami/java                         Bitnami Java Docker Image                   10                   [OK]
datadog/dd-trace-java-docker-build   Docker container to build Java APM Tracer   0                    [OK]

【示例四】只搜索官方镜像

$ docker search -f is-official=true java
NAME             DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
node             Node.js is a JavaScript-based platform for s…   11948     [OK]       
tomcat           Apache Tomcat is an open source implementati…   3399      [OK]       
java             DEPRECATED; use "openjdk" (or other JDK impl…   1976      [OK]       
ghost            Ghost is a free and open source blogging pla…   1557      [OK]       
couchdb          CouchDB is a database that uses JSON for doc…   487       [OK]       
jetty            Jetty provides a Web server and javax.servle…   385       [OK]       
amazoncorretto   Corretto is a no-cost, production-ready dist…   242       [OK]       
groovy           Apache Groovy is a multi-faceted language fo…   135       [OK]       
ibmjava          Official IBM® SDK, Java™ Technology Edition    103       [OK]       
tomee            Apache TomEE is an all-Apache Java EE certif…   98        [OK]

二. 进阶应用

格式化搜索输出:--format (注意:每个参数前面都有一个点)

  • 镜像描述:.Description
  • Star 数量:.StartCount
  • 官方镜像:.IsOfficial
  • 自动构建:.IsAutomated

【示例一】只显示镜像名和 Stars 收藏数

$ docker search --format "{{.Name}}: {{.StarCount}}" java
node: 11948
tomcat: 3399
java: 1976
ghost: 1557
couchdb: 487
jetty: 385
amazoncorretto: 242
groovy: 135
circleci/node: 129
ibmjava: 103
tomee: 98
ibmcom/ibmjava: 20
bitnami/java: 10
appdynamics/java-agent: 9
amazon/aws-lambda-java: 7
openwhisk/java8action: 2
circleci/java: 2
circleci/java-nginx: 1
ibmcom/java-websphere-traditional: 0
submitty/java: 0
airbyte/java-datadog-tracer-base: 0
kasmweb/java-dev: 0
datadog/dd-trace-java-docker-build: 0
ibmcom/java-acceleration-amd64: 0
cockroachdb/postgres-test: 0

【示例二】只显示镜像名、自动构建和官方的镜像

$ docker search --format "table {{.Name}}\t{{.IsAutomated}}\t{{.IsOfficial}}" java
NAME                                 AUTOMATED   OFFICIAL
node                                             [OK]
tomcat                                           [OK]
java                                             [OK]
ghost                                            [OK]
couchdb                                          [OK]
jetty                                            [OK]
amazoncorretto                                   [OK]
groovy                                           [OK]
circleci/node                                    
ibmjava                                          [OK]
tomee                                            [OK]
ibmcom/ibmjava                                   
bitnami/java                         [OK]        
appdynamics/java-agent                           
amazon/aws-lambda-java                           
openwhisk/java8action                            
circleci/java                                    
circleci/java-nginx                              
docker/dev-environments-java                     
submitty/java                                    
airbyte/java-datadog-tracer-base                 
kasmweb/java-dev                                 
datadog/dd-trace-java-docker-build   [OK]        
ibmcom/java-acceleration-amd64                   
ibmcom/java-websphere-traditional