Fundamentals 4 min read

Docker Day 3: Master the Three Core Image Commands – pull, images, and rm

This guide walks through the essential Docker image workflow—listing local images, pulling from public or private registries, removing images, tagging them, understanding the image‑to‑container relationship, and cleaning up unused resources with prune commands—for everyday development and CI/CD scenarios.

Tech Ocean
Tech Ocean
Tech Ocean
Docker Day 3: Master the Three Core Image Commands – pull, images, and rm

1. List Local Images

Use docker images or the shortcut docker image ls to display all images stored locally. The output includes columns for REPOSITORY (image name), TAG (version tag, default latest), IMAGE ID (unique identifier), CREATED, and SIZE.

2. Pull Images

Pulling without a tag defaults to the latest tag:

# Pull the latest Ubuntu image
docker pull ubuntu

# Pull a specific version
docker pull ubuntu:22.04
docker pull python:3.12-slim
docker pull mysql:8.0

# Pull from a private registry
docker pull myregistry.com/myimage:tag

Practical scenario: In CI/CD pipelines, running docker pull first caches layers and speeds up subsequent builds.

3. Remove Images

# Delete a single image
docker rmi nginx

# Force delete even if the image is in use
docker rmi -f ubuntu

# Remove all dangling images
docker image prune

# Delete every image (use with caution)
docker rmi $(docker images -q)

4. Tag Images

Because image IDs are hard to remember, assign a human‑readable tag:

# Official format: registry/username/repository:tag
docker tag hello-world myname/hello:1.0
# Verify the tag
docker images | grep hello

5. Image‑to‑Container Relationship

Image (read‑only) → Container (writable layer)
    ↓ COPY
Container changes affect only that container, not the underlying image.

Analogy: a class (template) versus an instance; modifying the instance does not alter the class definition.

6. Clean Up Unused Resources

If the development environment runs out of disk space, regularly prune:

# Remove stopped containers
docker container prune

# Remove build cache
docker builder prune

# Remove all unused images, containers, networks
docker system prune

# More thorough cleanup (including volumes)
docker system prune -a --volumes

Real‑world case: Running docker system prune before project delivery can free 10–50 GB of space.

7. Day 3 Summary

docker images

– list local images docker pull – download images from a registry docker rmi – delete images docker tag – assign a friendly tag docker system prune – clean up unused resources

Next up (Day 4): writing your first Dockerfile to package code into an image.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Dockerimage-managementdocker-prunedocker-pulldocker-rmi
Tech Ocean
Written by

Tech Ocean

Focused on AI programming, sharing ready-to-use development efficiency solutions.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.