Searching images
- Docker & Kubernetes course
- Beginner
- Lesson 68/82
- 4 min
Learn to search images with docker search.
Searching for images
docker search searches Docker Hub. The results show the star count and the OFFICIAL mark. Because many results come back, filters and limits are used:
$ docker search --filter is-official=true --limit 3 redis
NAME DESCRIPTION STARS OFFICIAL
redis Redis is the world’s fastest data platform … 13000 [OK]For the tag list and detailed documentation, Hub's web page is more convenient.
Inspecting an image
Before running an image you can look at its contents: which user it runs as, its open ports, its entry point. docker image inspect gives these; docker scout cves lists known security vulnerabilities:
docker image inspect -f '{{.Config.User}} {{.Config.ExposedPorts}} {{.Config.Entrypoint}}' redis:7
docker scout cves redis:7Practice Search and inspect
Write two commands: search only for official postgres images with at most 5 results; then show the exposed ports of the postgres:16 image with {{.Config.ExposedPorts}}.
Starter code
# buraya yazSample solution
docker search --filter is-official=true --limit 5 postgres
docker image inspect -f '{{.Config.ExposedPorts}}' postgres:16Expected output
NAME DESCRIPTION STARS OFFICIAL
postgres The PostgreSQL object-relational database … 14000 [OK]
map[5432/tcp:{}]
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 When choosing an image from search results, what is the most reliable sign?
- Having a long description
- Being uploaded most recently
- Being official (OFFICIAL) or a verified publisher Correct answer
- Having a short name
Explanation: Anyone can upload images to Hub; unknown images may contain malware.
2 Search only for official images.
docker search --filter ____=true nginx
docker search --filter is-official=true nginx
Explanation: is-official=true filters for official images.
3 Match.
| Term | Meaning |
|---|---|
docker search |
Search Hub |
[OK] OFFICIAL |
Official image |
image inspect |
Show the configuration |
scout cves |
Vulnerabilities |