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.
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:latestdocker save
Saves a local image to a tar archive file.
# docker save busybox > busybox.tar
# ls
busybox.tardocker 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:latestdocker 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:8ea3b23f387bedc5e3cee574742d748941443c328a75f511eb37b0d8b6164130docker 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
4c45f7885e579bbbdc795a1489585cad989558c19e832e94dce4dab48b7ea69cdocker start / docker stop
Starts a stopped container or stops a running one.
# docker stop bold_shockley
bold_shockleydocker 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_shockleySigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
