docker search

說明在 Docker Hub 中搜尋映像檔
用法docker search [選項] 搜尋詞

說明

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` 是搜尋返回的最大結果數。如果未設定值,則預設值由 Docker 常駐程式設定。

過濾 (--filter)

過濾旗標 (`-f` 或 `--filter`) 格式為 `key=value` 對。如果有多個過濾器,則傳遞多個旗標(例如 `--filter is-official=true --filter stars=3`)。

目前支援的過濾器為:

  • stars (int - 映像檔的星數)
  • is-automated (boolean - true 或 false) - 映像檔是否自動化(已棄用)
  • is-official (boolean - true 或 false) - 映像檔是否官方

stars (星數)

此範例顯示名稱包含「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

is-official (官方)

此範例顯示名稱包含「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 (官方)如果映像檔是官方的,則為「OK」
是否自動化若映像檔建置已自動化,則顯示「OK」(已棄用)

當您使用 --format 選項時,search 指令會完全按照範本宣告的格式輸出資料。如果您使用 table 指示,也會包含欄位標頭。

以下範例使用不含標頭的範本,並針對所有映像檔輸出以冒號 (:) 分隔的 NameStarCount 項目

$ 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