Cloud Native 11 min read

Master Docker Images: From Basics to Advanced Management

This article provides a comprehensive guide to Docker images, covering core concepts, image sources, essential commands for searching, pulling, tagging, inspecting, pruning, exporting, importing, and pushing images, along with practical examples and tips for effective container image management.

Open Source Linux
Open Source Linux
Open Source Linux
Master Docker Images: From Basics to Advanced Management

Docker Series Guide

Learning Docker requires mastering three core concepts: image, container, and repository.

Today we focus on the fundamentals of Docker images.

Docker Image Overview

1. What Is an Image?

A Docker image is a read‑only template. For VM administrators it is similar to a VM template, and for developers it can be thought of as a class.

In short, a Docker image is a minimal operating system without a kernel that can run applications.

For example, an image may contain a basic Ubuntu environment with Nginx installed, often called an Nginx image.

2. Where Do Images Come From?

Docker Hub

is the public registry maintained by Docker, containing many images. The Docker client defaults to downloading images from this registry.

Downloading the nginx image

Image Management Commands

Below are the key Docker commands for handling images.

1. Search Images

Docker search syntax

# Example: search for MySQL‑related images
docker search mysql

2. Pull Images

Docker pull syntax

Typically an image is identified by name + tag. For example, to pull the Ubuntu 18.04 image: docker pull ubuntu:18.04 If no tag is specified, Docker uses the latest tag by default.

Do not assume latest means “newest”; it is just a convention and does not trigger automatic updates.
# List images for repository web_repo
docker images web_repo

Tagging can change which tag points to which image ID.

3. View Images

1) List local images

Fields explained: REPOSITORY – source repository (e.g., ubuntu) TAG – version label IMAGE ID – unique identifier CREATED – creation time SIZE – image size

2) Inspect image details

The command returns JSON with author, architecture, layer digests, etc. Use -f to filter, e.g., to get the creation time.

3) View image history

Docker images consist of multiple layers. Use docker history to list each layer’s creation command.

Use --no-trunc to avoid truncating long commands.

4. Tag Images

Tag syntax:

docker tag ubuntu:latest myubuntu:v1

5. Delete Images

1) Delete by tag

# docker rmi myubuntu:v1
Untagged: myubuntu:v1
Removing a tag does not delete the underlying image if other tags exist.

2) Delete by image ID

# docker rmi 005d2078bdfa

If an image ID is referenced by multiple repositories, you must delete all tags or force removal with -f.

3) Prune unused images

Use docker image prune to clean up dangling layers and free space.
# docker image prune -f
Total reclaimed space: 1.6 GB

6. Export and Import Images

1) Export (save) an image

Export syntax:

# docker save -o /data/ubuntu:18.04.tar ubuntu:18.04
# ls /data
ubuntu:18.04.tar
The -o flag specifies the output file.

2) Import (load) an image

Use docker load to import a tar archive back into the local registry.

Import syntax:

# docker load -i ubuntu:18.04.tar
All image history and metadata are preserved.

7. Push Images to a Registry

Use docker push to upload an image to Docker Hub (login required).

Example:

# docker tag ubuntu:18.04 qinlulu/myubuntu:v1
# docker login
# docker push qinlulu/myubuntu:v1

Verify the image on https://hub.docker.com.

Command Summary

1. Search images

docker search mysql

2. Pull image

docker pull ubuntu:18.04

3. List local images

docker images

4. Inspect image

docker inspect ubuntu:18.04

5. View image history

docker history ubuntu:18.04

6. Tag image

docker tag ubuntu:latest myubuntu:v1

7. Delete image

docker rmi myubuntu:v1

8. Prune temporary images

docker image prune -f

9. Export image

docker save -o ubuntu.tar ubuntu:18.04

10. Import image

docker load -i ubuntu.tar

11. Push image

docker push qinlulu/myubuntu:v1
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.

CLICloud NativeDockerDevOpsContainerImage ManagementDocker Hub
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

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.