Searching Hub

Difficulty: Beginner

Question

How do you search for an image on Docker Hub from the command line, and how do you choose a trustworthy result?

Answer

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.

What the output tells you

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.

Useful flags

FlagExampleEffect
--filter is-official=truedocker search --filter is-official=true redisOnly Docker Official Images
--filter stars=Ndocker search --filter stars=500 postgresOnly repos with at least N stars
--limit Ndocker search --limit 5 pythonMax results (default 25, max 100)
--no-truncdocker search --no-trunc mongoFull descriptions
--format--format "{{.Name}}: {{.StarCount}}"Custom output for scripts

What docker search cannot do

  • It does not list tags. You cannot see 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.
  • It is Docker Hub centric. Most private registries (ECR, GCR, GHCR, Harbor) do not implement the search endpoint the CLI uses, so you browse them with their own CLI or UI.
  • Stars are not a security signal. A popular image can still be outdated or abandoned.

Choosing an image you can trust

  1. Prefer Docker Official Images or Verified Publisher images (for example images published by the vendor itself).
  2. Check the last update date and the Dockerfile or source repo on Hub.
  3. Pin a specific tag, or even a digest (image@sha256:...), rather than latest.
  4. Scan it with docker scout cves <image> or Trivy before using it in production.
  5. Be wary of typo-squatted names like 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.

Code examples

Search, filter and format

# 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.

Key points

  • docker search <term> queries Docker Hub and shows name, description, stars and official status
  • Filter with --filter is-official=true and --filter stars=N; cap results with --limit
  • It cannot list tags; use the Hub UI, imagetools inspect, skopeo or crane
  • Official images have no namespace prefix; prefer official or verified publisher images
  • Pin tags or digests and scan images before production use

Common follow-up questions

  • How would you find which tags exist for an image?
  • What makes an image 'official' on Docker Hub?
  • How do you scan an image for vulnerabilities?
  • Why should you avoid the latest tag in production?

Interview tips

  • Go beyond the command and talk about how you judge whether an image is safe to use
  • Mention that docker search does not show tags; it is a common gap interviewers probe

Concepts covered

docker search, Docker Hub, Official images, --filter and --limit, Image tags

More Docker & Containers questions