Skip to main content

Docker CLI Cheat Sheet 2026 — Quick CLI Command Reference

Docker CLI Cheat Sheet 2026 — Quick Command Reference

Docker CLI Cheat Sheet is the complete quick-reference of Docker CLI commands grouped by function. Copy any command with one click and find what you need with Ctrl+F in under 3 seconds.

Image Management

Action Command Useful flags
Image management
Docker Image Management Commands
Images
docker images
Image ls
docker image ls
Image
docker image
Build
docker image build -t [docker-username]/alpine-git
-git -t -username
Pull
docker image pull [image-name] | pull specified image from registry
-name
Image rm
docker image rm [image-name] | remove image for specified _image-name_
-name
Image rm
docker image rm [image-id] | remove image for specified _image-id_
-id
Search [image-name]
docker search [image-name] --filter "is-official=true" | find only official images having *[image-name]*
--filter -name -official

Container Lifecycle

Action Command Useful flags
Run
docker run -v /host:/container example/mysql
-v
Container
docker container
Container ps
docker container ps
Container ls
docker container ls | show all running containers
Container ls
docker container ls -a | show all containers regardless of state
-a
Container ls
docker container ls --filter "status=exited" --filter "ancestor=ubuntu" | show all container instances of the ubuntu image that have exited
--filter
Inspect
docker container inspect [container-name] | display detailed information about specified container
-name
Run
docker container run [image-name] | run container based on specified image
-name
Run
docker container run --rm [image-name] | run container based on specified imaged and immediately remove it once it stops
--rm -name
Run
docker container run --name fuzzy-box [image-name] | assign name and run container based on specified image
--name -box -name

Networks

Action Command Useful flags
Information on
Show information on one or more networks:
Commands removing
Docker Commands Removing Containers, Images, Volumes, And Networks
Provides a
Docker provides a command to clean up unused containers, networks, images, and volumes. This is useful to free up system resources.
List all networks
docker network ls
Create a bridge network
docker network create my-network
-network
Create network with subnet
docker network create --subnet=192.168.0.0/16 my-network
--subnet
Connect container to network
docker network connect my-network my-container
-container -network
Connect container with alias
docker network connect --alias db my-network my-container
--alias
Disconnect container from network
docker network disconnect my-network my-container
-container -network
Remove one or more networks
docker network rm my-network
-network
List network IDs only
docker network ls -q
-q

Volumes

Action Command Useful flags
Commands removing
Docker Commands Removing Containers, Images, Volumes, And Networks
Provides a
Docker provides a command to clean up unused containers, networks, images, and volumes. This is useful to free up system resources.
Create a volume
docker volume create my_volume
Inspect a volume
docker volume inspect my_volume
Remove a specific volume
docker volume rm my_volume
Mount volume in container
docker run -d --name mycontainer -v my_volume:/data nginx
-v
Mount using –mount syntax
docker run --mount source=my_volume,target=/app nginx
--mount
Backup volume to host
docker run --rm -v my_volume:/volume -v $(pwd):/backup alpine tar czf /backup/backup.tar.gz -C /volume .
--rm -v
Restore volume from backup
docker run --rm -v my_volume:/volume -v $(pwd):/backup alpine tar xzf /backup/backup.tar.gz -C /volume
--rm -v

Docker Compose

Action Command Useful flags
Compose
docker compose
Compose and
Docker Compose and Dockerfile
Run
docker run --help
--help
Build
docker build --rm=false .
--rm
Run
docker run -a stdin -a stdout -i -t ubuntu /bin/bash
-a -i -t
Run
docker run -a stdin -a stdout -a stderr ubuntu /bin/ls
-a
Run
docker run -v /host:/container example/mysql
-v
Configure
docker --config ~/testconfigs/ ps
--config

Docker Swarm

Action Command Useful flags
Swarm
docker swarm
Swarm commands
Docker Swarm Commands
Init
docker swarm init --advertise-addr 192.168.10.1
--advertise-addr
Swarm join-token
docker swarm join-token worker
-token
Swarm join-token
docker swarm join-token manager
-token
Run
docker run --help
--help
Build
docker build --rm=false .
--rm
Run
docker run -a stdin -a stdout -i -t ubuntu /bin/bash
-a -i -t
Run
docker run -a stdin -a stdout -a stderr ubuntu /bin/ls
-a
Run
docker run -v /host:/container example/mysql
-v
Configure
docker --config ~/testconfigs/ ps
--config

Registry & Push

Action Command Useful flags
Push
docker image push <usernameofregistry:Imagename: tag>
Pull
docker image pull [image-name] | pull specified image from registry
-name
Push
docker push [image]
Push
docker image push eon01/nginx

Cleanup (Prune)

Action Command Useful flags
Prune ⚠️
docker image prune
Prune ⚠️
docker system prune
Prune ⚠️
docker system prune -f
-f
Prune ⚠️
docker system prune -a
-a
Prune ⚠️
docker volume prune
Remove all unused images
docker image prune -a
-a
Prune system including volumes
docker system prune --volumes
--volumes
Prune all including volumes
docker system prune -a --volumes
-a --volumes
Prune resources older than 24h
docker system prune --filter until=24h
--filter until=24h

⚠️ Dangerous / Destructive Commands

These commands are irreversible. Verify your environment (dev/staging vs prod) before running them.

Action Command Warning
⚠️ Prune ⚠️
docker system prune
Irreversible — verify the target before running
⚠️ Prune ⚠️
docker system prune -f
Irreversible — verify the target before running
⚠️ Prune ⚠️
docker system prune -a
Irreversible — verify the target before running
⚠️ Prune ⚠️
docker system prune --volumes
Irreversible — verify the target before running
⚠️ Prune ⚠️
docker system prune -a --volumes
Irreversible — verify the target before running
⚠️ Prune ⚠️
docker system prune --filter until=24h
Irreversible — verify the target before running

FAQ — Frequently Asked Questions

What is the difference between Image Management and Container Lifecycle?

Each group in this Docker CLI cheat sheet covers a distinct area. Image Management focuses on its specific scope, while Container Lifecycle and the remaining groups cover networking, storage, security and diagnostics respectively.

How do I check the installed Docker CLI version?

Run the version command (usually docker version or docker --version). The output shows the client and, when applicable, the server version.

Why does Docker CLI return ‘permission denied’?

A ‘permission denied’ error in Docker CLI usually means the current user lacks sufficient privileges or credentials are not configured. Check: (1) assigned IAM/RBAC roles, (2) an active authentication context via the corresponding login command.

How do I filter Docker CLI output by status or name?

Use flags such as --filter, --selector or --query depending on the tool. You can also pipe into grep or jq to process JSON:

docker list | grep RUNNING

What is the fastest way to debug a Docker CLI error?

Add the verbose flag (--verbose, -v or --debug) to the failing command. This reveals the underlying HTTP/API calls and the full error response body.

Official sources & references

Commands cross-checked against vendor documentation and high-authority repositories: