Back to course

Lesson 7: Searching and Pulling Images from Docker Hub

Docker Zero to Hero: The Complete Containerization Course for Beginners

Lesson 7: Searching and Pulling Images from Docker Hub

Docker Hub is the world's largest public registry of container images. It hosts images maintained by Docker (Official Images) and images contributed by the community.

Searching for Images

You can search for images directly from your terminal using docker search.

Let's search for an official Python image:

bash docker search python

Output interpretation:

NAMEDESCRIPTIONSTARSOFFICIALAUTOMATED
pythonOfficial Python Docker image12000+[OK]
tiangolo/uwsgi-nginx-flaskFlask and Nginx setup500+[OK]
  • The [OK] under OFFICIAL indicates a trusted image maintained by Docker or the software vendor.
  • High STARS count usually indicates reliability.

Understanding Image Tags

Images are referenced by their name and a specific tag. The tag indicates the version or variant of the image.

  • nginx:latest (Default tag, usually the most recent stable version).
  • nginx:1.25.3 (Specific version).
  • python:3.11-alpine (Specific version and a lightweight base OS variant).

If you don't specify a tag, Docker assumes :latest.

Pulling Images

The docker pull command downloads an image from the registry to your local machine.

Pulling the Latest Tag (Implicit)

bash docker pull redis

Pulling a Specific Tag

It is highly recommended to use specific tags to ensure reproducibility.

bash docker pull node:18-slim docker pull postgres:15.5-alpine

Cleaning Up Local Images

If you no longer need an image, you can remove it using docker rmi (remove image).

bash docker rmi node:18-slim

Note: You cannot remove an image if a container based on it is still running or stopped. You must remove the container first.