码头搜索

描述在 Docker Hub 中搜索镜像
用法docker search [OPTIONS] TERM

描述

在Docker Hub中搜索 镜像

选项

选项默认描述
-f, --filter根据提供的条件过滤输出
--format使用 Go 模板进行漂亮的打印搜索
--limit最大搜索结果数
--no-trunc不要截断输出

例子

按名称搜索图像

此示例显示名称包含“busybox”的图像:

$ docker search busybox

NAME                             DESCRIPTION                                     STARS     OFFICIAL
busybox                          Busybox base image.                             316       [OK]
progrium/busybox                                                                 50
radial/busyboxplus               Full-chain, Internet enabled, busybox made...   8
odise/busybox-python                                                             2
azukiapp/busybox                 This image is meant to be used as the base...   2
ofayau/busybox-jvm               Prepare busybox to install a 32 bits JVM.       1
shingonoide/archlinux-busybox    Arch Linux, a lightweight and flexible Lin...   1
odise/busybox-curl                                                               1
ofayau/busybox-libc32            Busybox with 32 bits (and 64 bits) libs         1
peelsky/zulu-openjdk-busybox                                                     1
skomma/busybox-data              Docker image suitable for data volume cont...   1
elektritter/busybox-teamspeak    Lightweight teamspeak3 container based on...    1
socketplane/busybox                                                              1
oveits/docker-nginx-busybox      This is a tiny NginX docker image based on...   0
ggtools/busybox-ubuntu           Busybox ubuntu version with extra goodies       0
nikfoundas/busybox-confd         Minimal busybox based distribution of confd     0
openshift/busybox-http-app                                                       0
jllopis/busybox                                                                  0
swyckoff/busybox                                                                 0
powellquiring/busybox                                                            0
williamyeh/busybox-sh            Docker image for BusyBox's sh                   0
simplexsys/busybox-cli-powered   Docker busybox images, with a few often us...   0
fhisamoto/busybox-java           Busybox java                                    0
scottabernethy/busybox                                                           0
marclop/busybox-solr

显示未截断的描述(--no-trunc)

此示例显示名称包含“busybox”的图像,至少 3 颗星,并且输出中的描述不会被截断:

$ docker search --filter=stars=3 --no-trunc busybox

NAME                 DESCRIPTION                                                                               STARS     OFFICIAL
busybox              Busybox base image.                                                                       325       [OK]
progrium/busybox                                                                                               50
radial/busyboxplus   Full-chain, Internet enabled, busybox made from scratch. Comes in git and cURL flavors.   8

限制搜索结果(--limit)

该标志--limit是搜索返回的最大结果数。如果未设置值,则默认值由守护程序设置。

过滤(--filter)

过滤标志(-f--filter)格式为一key=value对。如果有多个过滤器,则传递多个标志(例如--filter is-official=true --filter stars=3)。

目前支持的过滤器有:

  • 星星(int - 图像的星星数量)
  • is-automated (布尔值 - true 或 false) - 图像是否自动化(已弃用)
  • is-official(布尔值 - true 或 false)- 图像是否官方

星星

此示例显示名称包含“busybox”且至少 3 颗星的图像:

$ docker search --filter stars=3 busybox

NAME                 DESCRIPTION                                     STARS     OFFICIAL
busybox              Busybox base image.                             325       [OK]
progrium/busybox                                                     50
radial/busyboxplus   Full-chain, Internet enabled, busybox made...   8

是官方的

此示例显示名称包含“busybox”的图像,至少 3 颗星,并且是官方版本:

$ docker search --filter is-official=true --filter stars=3 busybox

NAME      DESCRIPTION           STARS     OFFICIAL
busybox   Busybox base image.   325       [OK]

格式化输出(--format)

格式化选项 ( --format) 使用 Go 模板漂亮地打印搜索输出。

Go 模板的有效占位符是:

占位符描述
.Name图片名称
.Description图片描述
.StarCount图像的星数
.IsOfficial如果图像是官方的,则“确定”
.IsAutomated如果映像构建是自动化的,则“确定”(已弃用)

当您使用该--format选项时,该search命令将完全按照模板声明的方式输出数据。如果您使用该 table指令,也会包含列标题。

以下示例使用不带标题的模板,并 为所有图像输出用冒号 ( ) 分隔的Name和条目:StarCount:

$ docker search --format "{{.Name}}: {{.StarCount}}" nginx

nginx: 5441
jwilder/nginx-proxy: 953
richarvey/nginx-php-fpm: 353
million12/nginx-php: 75
webdevops/php-nginx: 70
h3nrik/nginx-ldap: 35
bitnami/nginx: 23
evild/alpine-nginx: 14
million12/nginx: 9
maxexcloo/nginx: 7

此示例输出表格格式:

$ docker search --format "table {{.Name}}\t{{.IsOfficial}}" nginx

NAME                                     OFFICIAL
nginx                                    [OK]
jwilder/nginx-proxy
richarvey/nginx-php-fpm
jrcs/letsencrypt-nginx-proxy-companion
million12/nginx-php
webdevops/php-nginx