Difficulty: Beginner
How do you search for an image on Docker Hub from the command line, and how do you choose a trustworthy result?
Run docker search <term>, for example docker search nginx. It queries Docker Hub and prints matching repositories with their name, description, star count and whether they are an official image. Narrow the list with --filter is-official=true, --filter stars=100 and --limit.
The columns are NAME, DESCRIPTION, STARS, OFFICIAL (older Docker versions also showed AUTOMATED, which is deprecated). Official images such as nginx, postgres and node live in the library namespace, so they have no user prefix. Anything with a prefix like someuser/nginx is a community or vendor image.
| Flag | Example | Effect |
|---|---|---|
--filter is-official=true | docker search --filter is-official=true redis | Only Docker Official Images |
--filter stars=N | docker search --filter stars=500 postgres | Only repos with at least N stars |
--limit N | docker search --limit 5 python | Max results (default 25, max 100) |
--no-trunc | docker search --no-trunc mongo | Full descriptions |
--format | --format "{{.Name}}: {{.StarCount}}" | Custom output for scripts |
node:20-alpine versus node:22-bookworm from it. Use the Docker Hub website, docker buildx imagetools inspect node:22-alpine to inspect a known tag, or tools like skopeo list-tags and crane ls to list tags in a registry.image@sha256:...), rather than latest.docker scout cves <image> or Trivy before using it in production.ngnix or random user images promising preconfigured stacks; malicious images with cryptominers have been found on public registries.In most companies, base images come from an approved internal list or a mirrored registry, so docker search is mainly a quick discovery tool on a developer laptop.
# Basic search
docker search redis
# Only official images, top 5
docker search --filter is-official=true --limit 5 postgres
# Script-friendly output
docker search --filter stars=1000 --format "{{.Name}}\t{{.StarCount}}\t{{.IsOfficial}}" python
# docker search cannot show tags; inspect a known tag instead
docker buildx imagetools inspect postgres:16-alpine
Official images show [OK] in the OFFICIAL column. The --format placeholders (Name, Description, StarCount, IsOfficial) are handy for piping results into other tools.
docker search, Docker Hub, Official images, --filter and --limit, Image tags