Docker常用命令使用详解(`docker search`)(二)

1.5docker serarch

1.5.1 描述

在Docker Hub中搜索镜像

1.5.2 用法

[OPTIONS]:可选项,即添加参数
TERM:搜索的项目

docker search [OPTIONS] TERM
1.5.3 参数说明
名称(简写) 默认值 描述
--filter , -f 根据提供的条件过滤输出
--format 使用Go模板进行格式化显示搜索
--limit 25 最多搜索结果数
--no-trunc 不要截断输出
1.5.4 命令及示例
1.5.4.1 按名称搜索镜像

搜索mysql相关的镜像(结果中显示名称包含“ mysql”的镜像)

docker search mysql
[root@VM-0-14-centos /]# docker search mysql
NAME                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql                             MySQL is a widely used, open-source relation…   10475     [OK]       
mariadb                           MariaDB is a community-developed fork of MyS…   3896      [OK]       
mysql/mysql-server                Optimized MySQL Server Docker images. Create…   769                  [OK]
percona                           Percona Server is a fork of the MySQL relati…   526       [OK]       
centos/mysql-57-centos7           MySQL 5.7 SQL database server                   87                   
mysql/mysql-cluster               Experimental MySQL Cluster Docker images. Cr…   79                   
centurylink/mysql                 Image containing mysql. Optimized to be link…   59                   [OK]
bitnami/mysql                     Bitnami MySQL Docker Image                      48                   [OK]
deitch/mysql-backup               REPLACED! Please use http://hub.docker.com/r…   41                   [OK]
prom/mysqld-exporter                                                              37                   [OK]
databack/mysql-backup             Back up mysql databases to... anywhere!         37                   
tutum/mysql                       Base docker image to run a MySQL database se…   35                   
schickling/mysql-backup-s3        Backup MySQL to S3 (supports periodic backup…   29                   [OK]
linuxserver/mysql                 A Mysql container, brought to you by LinuxSe…   27                   
centos/mysql-56-centos7           MySQL 5.6 SQL database server                   20                   
circleci/mysql                    MySQL is a widely used, open-source relation…   20                   
mysql/mysql-router                MySQL Router provides transparent routing be…   18                   
arey/mysql-client                 Run a MySQL client from a docker container      17                   [OK]
fradelg/mysql-cron-backup         MySQL/MariaDB database backup using cron tas…   11                   [OK]
yloeffler/mysql-backup            This image runs mysqldump to backup data usi…   7                    [OK]
openshift/mysql-55-centos7        DEPRECATED: A Centos7 based MySQL v5.5 image…   6                    
devilbox/mysql                    Retagged MySQL, MariaDB and PerconaDB offici…   3                    
ansibleplaybookbundle/mysql-apb   An APB which deploys RHSCL MySQL                2                    [OK]
jelastic/mysql                    An image of the MySQL database server mainta…   1                    
widdpim/mysql-client              Dockerized MySQL Client (5.7) including Curl…   1                    [OK]
[root@VM-0-14-centos /]# 
1.5.4.2 显示非截断的描述(--no-trunc

显示名称包含“mysql”,STARS至少为769的镜像,并且输出中的描述不被截断

docker search --filter=stars=769 --no-trunc mysql
[root@VM-0-14-centos /]# docker search --filter=stars=769 --no-trunc mysql
NAME                 DESCRIPTION                                                                                           STARS     OFFICIAL   AUTOMATED
mysql                MySQL is a widely used, open-source relational database management system (RDBMS).                    10475     [OK]       
mariadb              MariaDB is a community-developed fork of MySQL intended to remain free under the GNU GPL.             3896      [OK]       
mysql/mysql-server   Optimized MySQL Server Docker images. Created, maintained and supported by the MySQL team at Oracle   769                  [OK]
[root@VM-0-14-centos /]# 
1.5.4.3 限制搜索结果(--limit

--limit是搜索返回的最大结果数。此值的范围可以是1到100。默认值为--limit 25
只显示5个关于mysql的镜像

docker search mysql --limit 5
[root@VM-0-14-centos /]# docker search mysql --limit 5
NAME                  DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql                 MySQL is a widely used, open-source relation…   10475     [OK]       
mysql/mysql-server    Optimized MySQL Server Docker images. Create…   769                  [OK]
mysql/mysql-cluster   Experimental MySQL Cluster Docker images. Cr…   79                   
bitnami/mysql         Bitnami MySQL Docker Image                      48                   [OK]
circleci/mysql        MySQL is a widely used, open-source relation…   20                   
[root@VM-0-14-centos /]# 
1.5.4.3 过滤

-f--filter)格式:(key=value)键值对的形式。
若多个过滤器,则传递多个标志(例如--filter is-automated=true --filter stars=5

过滤条件 值类型 描述
stars int 镜像具有的star数量
is-automated boolean 镜像是否自动构建
is-official boolean 是否为官方镜像
#STARS至少为769的mysql镜像
docker search --filter stars=769 mysql
#显示名称包含mysql镜像为自动构建的
docker search --filter is-automated=true mysql
#显示名称包含mysql为官方版本的镜像
docker search --filter is-official=true mysql
[root@VM-0-14-centos /]# docker search --filter stars=769 mysql
NAME                 DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql                MySQL is a widely used, open-source relation…   10475     [OK]       
mariadb              MariaDB is a community-developed fork of MyS…   3896      [OK]       
mysql/mysql-server   Optimized MySQL Server Docker images. Create…   769                  [OK]
#######################################
[root@VM-0-14-centos /]# docker search --filter is-automated=true mysql
NAME                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql/mysql-server                Optimized MySQL Server Docker images. Create…   769                  [OK]
centurylink/mysql                 Image containing mysql. Optimized to be link…   59                   [OK]
bitnami/mysql                     Bitnami MySQL Docker Image                      48                   [OK]
deitch/mysql-backup               REPLACED! Please use http://hub.docker.com/r…   41                   [OK]
prom/mysqld-exporter                                                              37                   [OK]
schickling/mysql-backup-s3        Backup MySQL to S3 (supports periodic backup…   29                   [OK]
arey/mysql-client                 Run a MySQL client from a docker container      17                   [OK]
fradelg/mysql-cron-backup         MySQL/MariaDB database backup using cron tas…   11                   [OK]
yloeffler/mysql-backup            This image runs mysqldump to backup data usi…   7                    [OK]
ansibleplaybookbundle/mysql-apb   An APB which deploys RHSCL MySQL                2                    [OK]
widdpim/mysql-client              Dockerized MySQL Client (5.7) including Curl…   1                    [OK]
[root@VM-0-14-centos /]# 
#############################################
[root@VM-0-14-centos /]# docker search --filter is-official=true mysql
NAME      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql     MySQL is a widely used, open-source relation…   10475     [OK]       
mariadb   MariaDB is a community-developed fork of MyS…   3896      [OK]       
percona   Percona Server is a fork of the MySQL relati…   526       [OK]       
[root@VM-0-14-centos /]# 
1.5.4.4 格式化输出

--format)使用Go模板格式化搜索输出

Go模板的有效占位符为

占位符 描述
.Name 镜像名称
.Description 镜像描述
.StarCount 镜像的stars数量
.IsOfficial 显示"OK",则镜像是官方的
.IsAutomated 显示"OK",则镜像的构建是自动的

显示包含mysql镜像的名称和stars数量

#显示包含mysql镜像的名称和stars数量
docker search --format "{{.Name}}: {{.StarCount}}" mysql
[root@VM-0-14-centos /]# docker search --format "{{.Name}}: {{.StarCount}}" mysql
mysql: 10475
mariadb: 3896
mysql/mysql-server: 769
percona: 526
centos/mysql-57-centos7: 87
mysql/mysql-cluster: 79
centurylink/mysql: 59
bitnami/mysql: 48
deitch/mysql-backup: 41
prom/mysqld-exporter: 37
databack/mysql-backup: 37
tutum/mysql: 35
schickling/mysql-backup-s3: 29
linuxserver/mysql: 27
centos/mysql-56-centos7: 20
circleci/mysql: 20
mysql/mysql-router: 18
arey/mysql-client: 17
fradelg/mysql-cron-backup: 11
yloeffler/mysql-backup: 7
openshift/mysql-55-centos7: 6
devilbox/mysql: 3
ansibleplaybookbundle/mysql-apb: 2
widdpim/mysql-client: 1
jelastic/mysql: 1
[root@VM-0-14-centos /]# 

以表格形式显示mysql镜像名称、自动构建、是否为官方

#以表格形式显示
docker search --format "table {{.Name}}\t{{.IsAutomated}}\t{{.IsOfficial}}" mysql
[root@VM-0-14-centos /]# docker search --format "table {{.Name}}\t{{.IsAutomated}}\t{{.IsOfficial}}" mysql
NAME                              AUTOMATED   OFFICIAL
mysql                                         [OK]
mariadb                                       [OK]
mysql/mysql-server                [OK]        
percona                                       [OK]
centos/mysql-57-centos7                       
mysql/mysql-cluster                           
centurylink/mysql                 [OK]        
bitnami/mysql                     [OK]        
deitch/mysql-backup               [OK]        
prom/mysqld-exporter              [OK]        
databack/mysql-backup                         
tutum/mysql                                   
schickling/mysql-backup-s3        [OK]        
linuxserver/mysql                             
centos/mysql-56-centos7                       
circleci/mysql                                
mysql/mysql-router                            
arey/mysql-client                 [OK]        
fradelg/mysql-cron-backup         [OK]        
yloeffler/mysql-backup            [OK]        
openshift/mysql-55-centos7                    
devilbox/mysql                                
ansibleplaybookbundle/mysql-apb   [OK]        
jelastic/mysql                                
widdpim/mysql-client              [OK]        
[root@VM-0-14-centos /]# 

Docker常用命令使用详解(docker pull)(三)

你可能感兴趣的:(Docker,docker,命令)