Operations 5 min read

Master Docker: Essential Commands for Images, Containers, and Management

This guide explains the key Docker CLI commands—including image listing, pulling, saving, loading, removing, running, starting, stopping, and inspecting containers—providing clear examples and output to help you efficiently manage Docker images and containers.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Docker: Essential Commands for Images, Containers, and Management

Docker image vs images

The docker images command lists available images and can be used directly, whereas docker image is a parent command that requires sub‑commands such as ls to display images.

# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
busybox      latest    a9d583973f65   2 years ago   1.23MB
nginx        latest    298ec0e28760   2 years ago   133MB
# docker image
Usage:  docker image COMMAND
Manage images
Commands:
  build   Build an image from a Dockerfile
  history Show the history of an image
  import  Import the contents from a tarball to create a filesystem image
  inspect Display detailed information
# docker image ls   (alias for docker images)

docker pull

Pulls a specified image from a registry to the local host.

# docker pull alpine
Using default tag: latest
latest: Pulling from library/alpine
ca3cd42a7c95: Pull complete
Digest: sha256:e103c1b4bf019dc290bcc7aca538dc2bf7a9d0fc836e186f5fa34945c5168310
Status: Downloaded newer image for alpine:latest
docker.io/library/alpine:latest

docker save

Saves a local image to a tar archive file.

# docker save busybox > busybox.tar
# ls
busybox.tar

docker load

Loads an image from a tar archive created by docker save.

# docker load -i busybox.tar
2983725f2649: Loading layer   1.45MB/1.45MB
Loaded image: busybox:latest

docker rmi

Removes one or more images from the local Docker registry.

# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
alpine       latest    49f356fa4513   2 years ago   5.61MB
busybox      latest    a9d583973f65   2 years ago   1.23MB
nginx        latest    298ec0e28760   2 years ago   133MB
# docker rmi alpine
Untagged: alpine:latest
Untagged: alpine@sha256:e103c1b4bf019dc290bcc7aca538dc2bf7a9d0fc836e186f5fa34945c5168310
Deleted: sha256:49f356fa4513676c5e22e3a8404aad6c7262cc7aaed15341458265320786c58c
Deleted: sha256:8ea3b23f387bedc5e3cee574742d748941443c328a75f511eb37b0d8b6164130

docker run

Creates and starts a new container from an image. Common flags:

-t : Allocate a pseudo‑TTY.

-i : Keep STDIN open (interactive).

-d : Run container in detached (background) mode.

# docker run -itd nginx
4c45f7885e579bbbdc795a1489585cad989558c19e832e94dce4dab48b7ea69c

docker start / docker stop

Starts a stopped container or stops a running one.

# docker stop bold_shockley
bold_shockley

docker ps

Lists containers. Without options, only running containers are shown; use -a to list all containers.

# docker ps
CONTAINER ID   IMAGE   COMMAND   CREATED   STATUS   PORTS   NAMES
# docker ps -a
CONTAINER ID   IMAGE   COMMAND                  CREATED         STATUS                     PORTS   NAMES
4c45f7885e57   nginx   "/docker-entrypoint.…"   8 minutes ago   Exited (0) 3 minutes ago           bold_shockley
Docker illustration
Docker illustration
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.

OperationsImage
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

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.