Cloud Native 6 min read

Comprehensive Guide to Docker Core Commands (2026 Edition)

This article provides a complete reference of essential Docker commands—including version, info, images, pull, run, ps, stop/start, exec, logs, stats, rm, rmi, prune, and inspect—along with example usages and typical scenarios such as environment verification, container management, and performance troubleshooting.

Architect Chen
Architect Chen
Architect Chen
Comprehensive Guide to Docker Core Commands (2026 Edition)

1. Check Docker version

Command: docker version Outputs client and server version details, useful for verifying installation success, confirming client‑server versions, and diagnosing compatibility issues.

2. View Docker system information

Command: docker info Shows runtime environment details, including container count, image count, storage driver (e.g., overlay2), CPU, memory, Docker root directory, and cgroup information. Typical scenarios: server inspection, environment checks, performance debugging.

3. List images

Command: docker images (alias docker image ls)

Displays local images with columns REPOSITORY, TAG, IMAGE ID, etc. Example output shows nginx and mysql images.

4. Pull images

Command: docker pull <image>[:tag] Downloads an image from a registry. Specify a version tag (e.g., docker pull mysql:8.4) or pull the latest tag ( docker pull redis:latest). Use cases: initializing environments, deploying applications, updating images.

5. Run containers

Command: docker run <image> Runs a container from an image. Examples:

Run nginx: docker run nginx Run nginx in detached mode: docker run -d nginx Port mapping: docker run -d -p 80:80 nginx Assign container name:

docker run --name my-nginx -p 80:80 nginx

6. List running containers

Command: docker ps (add -a to list all containers).

7. Stop and start containers

Stop: docker stop <container> Start: docker start <container> Force stop:

docker kill <container>

8. Execute commands inside a container

Command: docker exec -it <container> <command> Examples: docker exec -it nginx bash or docker exec -it redis sh. Use cases: modify configuration, view logs, debug programs.

9. View container logs

Command: docker logs <container> Real‑time logs: docker logs -f <container> Tail last 100 lines: docker logs --tail 100 <container> Show timestamps:

docker logs -t <container>

10. Monitor container resources

Command: docker stats Outputs CPU %, MEM USAGE, NET I/O, BLOCK I/O. Useful for online performance troubleshooting such as CPU spikes, memory leaks, or network anomalies.

11. Remove containers

Command: docker rm <container> Remove multiple containers: docker rm id1 id2 id3 Force removal: docker rm -f <container> Delete all stopped containers:

docker container prune -a

12. Remove images

Command: docker rmi <image> Delete by ID: docker rmi image_id Remove unused images: docker image prune Delete all unused resources (images, networks, build cache): docker system prune -a – use with caution in production.

13. Inspect containers or images

Command: docker inspect <name_or_id> Provides detailed configuration of a container or image.

Note: docker system prune -a will delete unused images, networks, and build caches; exercise caution in production environments.
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.

cloud nativedockerdevopslinuxcontainersystem-administrationcommand-line
Architect Chen
Written by

Architect Chen

Sharing over a decade of architecture experience from Baidu, Alibaba, and Tencent.

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.