Docker search Command
docker search The command is used to search for images in Docker Hub or other registries.
docker search The command helps users find and obtain the required images, and provides functions to filter and sort search results.
Syntax
docker search [OPTIONS] TERM
TERM: The keyword to search for.
Common options:
-
--automated :Only list images of the automated build type;
-
--no-trunc :Show the full image description;
-
-f
: List images with a star count no less than the specified value.
** 1. Search for images**
docker search ubuntu
This searches Docker Hub for images containing the keyword ubuntu.
** 2. Limit the number of search results returned**
docker search --limit 5 ubuntu
This searches Docker Hub for images containing the keyword ubuntu and returns only the first 5 results.
** 3. Filter search results**
docker search --filter stars=50 ubuntu
This searches Docker Hub for images containing the keyword ubuntu and returns only images with a stars count of at least 50.
** 4. Do not truncate the output**
docker search --no-trunc ubuntu
This searches Docker Hub for images containing the keyword ubuntu and shows the full image descriptions.
** 5. Custom format output**
docker search --format "{{.Name}}: {{.StarCount}} stars" ubuntu
This searches Docker Hub for images containing the keyword ubuntu and displays image names and star counts in a specified format.
Example
1. Search for the Ubuntu image
docker search ubuntu
输出示例:
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
ubuntu Ubuntu is a Debian-based Linux operating sys… 10000 [OK]
dorowu/ubuntu-desktop-lxde-vnc Ubuntu with openssh-server and NoVNC 4000 [OK]
rastasheep/ubuntu-sshd Dockerized SSH service, built on top of offi… 2000 [OK]
Parameter Description:
**NAME: ** the name of the image repository source
**DESCRIPTION: ** the image's description
**OFFICIAL: ** whether it is officially released by docker
**stars: ** similar to stars on GitHub, indicating likes or favorites.
**AUTOMATED: ** automated build.
2. Limit the number of returned results
docker search --limit 3 ubuntu
Example output:
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
ubuntu Ubuntu is a Debian-based Linux operating sys… 10000 [OK]
dorowu/ubuntu-desktop-lxde-vnc Ubuntu with openssh-server and NoVNC 4000 [OK]
rastasheep/ubuntu-sshd Dockerized SSH service, built on top of offi… 2000 [OK]
3. Filter search results
docker search --filter stars=1000 ubuntu
Example output:
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
ubuntu Ubuntu is a Debian-based Linux operating sys… 10000 [OK]
dorowu/ubuntu-desktop-lxde-vnc Ubuntu with openssh-server and NoVNC 4000 [OK]
rastasheep/ubuntu-sshd Dockerized SSH service, built on top of offi… 2000 [OK]
4. Custom format output
docker search --format "{{.Name}}: {{.StarCount}} stars" ubuntu
Example output:
ubuntu: 10000 stars
dorowu/ubuntu-desktop-lxde-vnc: 4000 stars
rastasheep/ubuntu-sshd: 2000 stars
Notes
- Search results may contain a large number of images; you can use filtering and sorting options to narrow them down.
- Ensure you use accurate keywords to get relevant results.
docker searchDocker Hub is searched by default; to search other registries, configure the Docker client accordingly.
docker search The command is an important tool for finding Docker images. By specifying keywords and options, users can efficiently search for and obtain the required images in a Docker registry. This command applies to various scenarios, including finding images with specific functions, obtaining highly rated images, and customizing result display.
Docker Command Reference