Essential Docker Commands Cheat Sheet: Quick Reference for Developers
This comprehensive guide presents over twenty essential Docker CLI commands, covering image management, container lifecycle, registry operations, and system cleanup, with clear syntax examples and practical use‑case snippets to help developers and DevOps engineers work efficiently with containers.
Essential Docker Commands Cheat Sheet
Introduction
Docker has become the de‑facto standard for containerised applications; developers and DevOps engineers need to master it.
While Docker offers many advanced features, a core set of commands is used daily.
This guide lists more than 20 basic Docker commands and their typical use cases.
1. Docker General Commands
docker info
docker info– display system‑wide information.
Syntax:
docker infodocker --help
docker --help– show Docker help; also works on sub‑commands.
Syntax:
docker <subcommands> --help2. Docker Registry Commands
docker login
docker login– log in to a Docker registry (default if no server is specified).
Syntax:
docker login <options> <registry>docker logout
docker logout– log out from a Docker registry.
Syntax:
docker logout <registry_url>3. Docker Image Commands
docker build
docker build– build a custom image from a Dockerfile.
Syntax:
docker build -t <image_name> <options> <dockerfile_path>docker tag
docker tag <source_image> <target_image>– create a new tag for an existing image.
docker images
docker images– list all images on the system.
Syntax:
docker images <options>docker pull
docker pull <image_name>– download an image from a registry.
docker push
docker push <image_name>– upload an image to a registry.
docker save
docker save -o <output_file> <image_name>– export an image to a .tar file.
docker load
docker load -i <path_to_image_archive>– import an image from a .tar file.
docker rmi
docker rmi <image_name>– remove one or more images.
4. Docker Container Commands
docker run
docker run <options> <image>– create and start a new container from an image.
docker ps
docker ps– list running containers. docker ps -a – list all containers, including stopped ones.
docker stop / start / restart
docker stop <container_name>– stop a running container. docker start <container_name> – start a stopped container. docker restart <container_name> – restart a container.
docker rm
docker rm <container>– remove a stopped container. docker rm -f <container> – force‑remove a running container.
docker logs
docker logs <container>– retrieve logs from a container. docker logs --tail 100 <container> – show the last 100 lines.
docker exec
docker exec -it <container> /bin/bash– start an interactive Bash shell inside a container. docker exec <container> ls -l /app – run an arbitrary command inside a container.
docker cp
docker cp <container>:<source_path> <dest_path>– copy files from a container to the host.
docker cp <host_path> <container>:<dest_path>– copy files from the host into a container.
5. Docker Cleanup
docker system prune
docker system prune– remove all stopped containers, dangling images, and unused networks. docker system prune -a – additionally remove all unused images.
Signed-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.
