Operations 10 min read

Essential Docker Commands Cheat Sheet: 20+ Must‑Know Commands

This comprehensive Docker cheat sheet walks developers, DevOps engineers, and system administrators through over twenty essential Docker commands—including image building, registry authentication, container lifecycle management, and system cleanup—providing clear syntax and practical usage examples for efficient container operations.

Raymond Ops
Raymond Ops
Raymond Ops
Essential Docker Commands Cheat Sheet: 20+ Must‑Know Commands

Docker Essential Commands Cheat Sheet

Docker has become the de‑facto standard for containerising applications. Whether you are a developer, DevOps engineer or system administrator, mastering the most frequently used Docker commands is essential for efficient deployment and management of modern, portable applications.

1. General Docker Commands

docker info

– Display system‑wide information. docker --help – Show help for Docker and its sub‑commands.

2. Docker Registry

docker login

– Log in to a Docker registry (default if no server specified). docker logout – Log out and remove stored credentials.

3. Docker Images

docker build -t <your_image_name> [options] <dockerfile_path>

– Build a custom image from a Dockerfile. docker tag <source_image> <target_image> – Create a new tag for an existing image. docker images – List all images on the host (add -a to include intermediate images). docker pull <image_name> – Download an image from a registry. docker push <image_name> – Upload an image to a registry. docker save -o <output_file> <image_name> – Export an image to a .tar file. docker load -i <image_archive.tar> – Import an image from a .tar file. docker rmi <image_name[:tag]> – Remove one or more images.

4. Docker Containers

docker run [options] <image>

– Create and start a new container (options for naming, port mapping, environment variables, volume mounts, network mode, privileged mode, interactive shell, etc.). docker ps – List running containers (add -a to include stopped ones). docker stop/start/restart <container_name> – Manage container lifecycle. docker rm <container_name> – Remove a stopped container (add -f to force removal of a running container). docker logs [options] <container_name> – Retrieve container logs. docker exec [options] <container_name> <command> – Run a command inside a running container (e.g., docker exec -it mycontainer /bin/bash). docker cp <container>:/path/to/file /host/path – Copy files between a container and the host.

5. Docker Cleanup

docker system prune

– Remove all stopped containers, unused images and networks. docker system prune -a – Same as above but also removes all unused images.

These commands cover the most common tasks for building, distributing, running, and maintaining Docker containers and images.

Docker cheat sheet diagram
Docker cheat sheet diagram
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.

DockerDevOpsContainercommand-lineDockerfile
Raymond Ops
Written by

Raymond Ops

Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.

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.