Docker Image Management

Manage Docker images effectively: pull, tag, push, save, load, and clean up images. Learn about image layers, dangling images, and registry workflows.

Images

Detailed Explanation

Working with Docker Images

Docker images are read-only templates used to create containers. Understanding image management is essential for efficient Docker workflows.

Pulling Images

# Pull from Docker Hub
docker pull node:20-alpine

# Pull specific platform
docker pull --platform linux/amd64 python:3.12

# Pull from a private registry
docker pull ghcr.io/myorg/my-app:v1.0

Tagging Images

Tags are aliases for image IDs. Use them for versioning and registry organization:

# Tag for a private registry
docker tag my-app:latest registry.example.com/my-app:v2.0

# Add multiple tags
docker tag my-app:latest my-app:v2.0
docker tag my-app:latest my-app:stable

Pushing to a Registry

docker login ghcr.io
docker tag my-app ghcr.io/myorg/my-app:v1.0
docker push ghcr.io/myorg/my-app:v1.0

Exporting and Importing

For air-gapped environments or offline transfers:

# Save to tar
docker save -o my-app.tar my-app:v1.0

# Compress
docker save my-app:v1.0 | gzip > my-app.tar.gz

# Load on another machine
docker load -i my-app.tar.gz

Cleaning Up Images

# Remove specific image
docker rmi node:18-alpine

# Remove dangling images (untagged)
docker image prune

# Remove all unused images
docker image prune -a

# List dangling images
docker images --filter dangling=true

Use Case

Maintaining clean development machines, preparing images for deployment to production registries, transferring images in restricted network environments, and managing multi-version image libraries.

Try It — Docker CLI Reference

Open full tool