Docker Commands Cheat Sheet 2026 — Reference for DevOps

By Jay, editor

Published: March 20, 2026 · Updated: October 7, 2026 · 12 min read

Table of Contents

  1. Container Management
  2. Image Commands
  3. Volumes
  4. Networks
  5. Docker Compose
  6. Logs & Monitoring
  7. Building Images
  8. Registry & Pushing
  9. System Cleanup
  10. Power Tips

Docker packages and runs applications in containers. This cheat sheet covers the commands used most often — from basic container management to Docker Compose and system cleanup.

1. Container Management

CommandWhat it does
docker psList running containers
docker ps -aList all containers including stopped
docker run -d --name my-app -p 8080:80 <image>Run detached with name and port mapping
docker run -it <image> bashRun with interactive terminal
docker run --rm <image>Auto-remove container when it exits
docker run -e KEY=value <image>Set environment variable
docker run -v /host/path:/container/path <image>Bind-mount a host directory into the container
docker start / stop / restart <container>Start, stop, or restart a container
docker kill <container>Immediately force-stop (SIGKILL)
docker rm <container>Remove a stopped container
docker rm -f <container>Force-remove a running container
docker exec -it <container> bashOpen shell inside running container
docker inspect <container>Show detailed container info (JSON)
docker cp <container>:/path ./localCopy file from container to host
docker statsLive CPU/memory/network usage
Tip: Stop all running containers at once: docker stop $(docker ps -q)

2. Image Commands

CommandWhat it does
docker imagesList local images
docker pull <image>:<tag>Download image from registry
docker rmi <image>Remove a local image
docker tag <image> <new-name>:<tag>Tag an image with a new name
docker history <image>Show image layer history
docker save -o image.tar <image>Export image to tar file
docker load -i image.tarLoad image from tar file

3. Volumes

CommandWhat it does
docker volume lsList all volumes
docker volume create <name>Create a named volume
docker volume inspect <name>Show volume details
docker volume rm <name>Remove a volume
docker volume pruneRemove unused anonymous volumes (-a for named ones too)
docker run -v my-vol:/app/data <image>Mount named volume into container

4. Networks

CommandWhat it does
docker network lsList all networks
docker network create <name>Create a custom bridge network
docker network connect <network> <container>Connect container to a network
docker network disconnect <network> <container>Disconnect container from network
docker network pruneRemove all unused networks
docker run --network=host <image>Connect the container to the host network

5. Docker Compose

Docker Compose manages multi-container applications defined in a Compose file such as compose.yaml.

CommandWhat it does
docker compose up -dStart all services in background
docker compose up --buildRebuild images before starting
docker compose downStop and remove containers and networks
docker compose down -vAlso remove volumes
docker compose psList service containers
docker compose logs -f <service>Follow logs for a specific service
docker compose exec <service> bashOpen shell in a running service
docker compose restart <service>Restart a specific service
docker compose pullPull the images for all services
docker compose run <service> <cmd>Run a one-off command in a service
docker compose configValidate and view merged compose config

6. Logs & Monitoring

CommandWhat it does
docker logs -f <container>Follow log output in real time
docker logs --tail 100 <container>Show last 100 log lines
docker logs --since 1h <container>Show logs from last hour
docker stats <container>Resource usage for specific container
docker eventsStream real-time Docker daemon events

7. Building Images

CommandWhat it does
docker build -t myapp:1.0 .Build and tag from current directory
docker build -f Dockerfile.prod .Build using a specific Dockerfile
docker build --no-cache .Build without cache (fresh build)
docker build --build-arg KEY=val .Pass build-time variable
docker build --target <stage> .Build up to a specific multi-stage target
Multi-stage builds: with --target the named stage becomes the final stage of the image and the builder skips the stages after it, which lets you build only one stage during development.

8. Registry & Pushing

CommandWhat it does
docker loginLog in to Docker Hub
docker login <registry-host>Log in to a private registry
docker tag myapp:1.0 myuser/myapp:1.0Tag image for Docker Hub
docker push myuser/myapp:1.0Push image to Docker Hub
docker search nginxSearch Docker Hub for images

9. System Cleanup

CommandWhat it does
docker system dfShow disk usage by Docker
docker system pruneRemove stopped containers, unused networks, dangling images and unused build cache
docker system prune -aAlso remove all unused images
docker system prune -a --volumesWidest cleanup: also unused anonymous volumes (named volumes are kept)
docker container pruneRemove all stopped containers
docker image prune -aRemove all unused images
docker builder pruneClear dangling build cache (-a for all unused cache)
Warning: docker system prune -a --volumes removes every unused image and every unused anonymous volume. Named volumes are kept; docker volume prune -a is the command that deletes those. Back up data before running either in production.

10. Power Tips & One-liners

CommandWhat it does
docker stop $(docker ps -q)Stop all running containers
docker rm $(docker ps --filter status=exited -q)Remove all exited containers
docker rmi $(docker images -q)Remove all local images (one used by a running container needs -f)
docker run --rm -it alpine shQuick throwaway Alpine shell
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <c>Get container IP address
docker run --memory 512m --cpus 1.5 <image>Limit container resources
docker diff <container>Show changed files vs the original image
docker commit <container> my-snapshotSave container state as a new image

Also explore: Docker CLI shortcuts and DevOps tools

View Docker Shortcuts Reference

How to read the sections

The commands are grouped by what they act on — containers, images, volumes, networks, Compose — which matches how Docker's own CLI is organised (docker container, docker image). The short forms most people type (docker ps, docker rm) are aliases of those, and the sheet uses the long form only where no short one exists (docker container prune, docker image prune). Placeholders in angle brackets are values to replace; names such as my-app, my-vol and myapp:1.0 are examples.

Three habits the sheet cannot teach

First, name containers and networks; --name on run turns every later command from an ID lookup into a word. Second, keep state in named volumes, not in the container, so docker rm is never a data-loss event. Third, read docker system df before pruning, because the cleanup commands delete exactly what they say. The Docker reference page on this site has a row for each of these — docker run --name, mounting a named volume, docker system df and the prune commands — with a one-line note on what each does.

Compose versus plain docker

Anything with more than one container belongs in a compose.yaml, and the Compose section of the sheet replaces most of the run-and-network commands above it: docker compose up -d creates the network, volumes and containers from the file, and down removes the containers and network again; the volumes stay unless you add -v. The plain commands remain the tools for inspecting what Compose created.