Docker Cheat Sheet
Quick reference for Docker commands — containers, images, volumes, and compose
docker run <image>Create and start a container from an image
docker run -d --name web -p 8080:80 nginxRun container detached with name and port mapping
docker run -it ubuntu bashRun container interactively with a shell
docker run --rm <image>Run container and auto-remove on exit
docker run -v /host:/container <image>Run with a bind mount
docker run -e VAR=value <image>Run with an environment variable
docker run --env-file .env <image>Run with environment variables from a file
docker run --restart unless-stopped <image>Auto-restart container unless manually stopped
docker psList running containers
docker ps -aList all containers (including stopped)
docker start <container>Start a stopped container
docker stop <container>Gracefully stop a running container
docker restart <container>Restart a container
docker rm <container>Remove a stopped container
docker rm -f <container>Force remove a running container
docker rename old_name new_nameRename a container
docker pause <container>Pause all processes in a container
docker unpause <container>Unpause a paused container
docker port <container>List port mappings for a container
docker imagesList all local images
docker images -aList all images including intermediate layers
docker pull <image>:<tag>Download an image from a registry
docker push <image>:<tag>Upload an image to a registry
docker rmi <image>Remove a local image
docker rmi $(docker images -q -f dangling=true)Remove all dangling images
docker tag <image> <repo>:<tag>Create a tag pointing to an image
docker history <image>Show the history/layers of an image
docker save -o image.tar <image>Save image to a tar archive
docker load -i image.tarLoad image from a tar archive
docker image inspect <image>Display detailed image information as JSON
docker volume create <name>Create a named volume
docker volume lsList all volumes
docker volume inspect <name>Show detailed information about a volume
docker volume rm <name>Remove a volume
docker volume pruneRemove all unused volumes
docker run -v mydata:/data <image>Mount a named volume into a container
docker run -v $(pwd):/app <image>Bind mount current directory into container
docker run --mount type=tmpfs,dst=/tmp <image>Mount a tmpfs (in-memory) volume
docker network create <name>Create a new network
docker network create --driver bridge mynetCreate a bridge network
docker network lsList all networks
docker network inspect <name>Show detailed information about a network
docker network rm <name>Remove a network
docker network connect <network> <container>Connect a running container to a network
docker network disconnect <network> <container>Disconnect a container from a network
docker network pruneRemove all unused networks
docker run --network=mynet <image>Run container attached to a specific network
docker compose up -dStart all services in detached mode
docker compose downStop and remove all services, networks
docker compose down -vStop and remove services, networks, AND volumes
docker compose buildBuild or rebuild all service images
docker compose build --no-cacheBuild without using cache
docker compose psList running compose services
docker compose logs -f <service>Follow logs of a specific service
docker compose logs --tail 50Show last 50 lines of logs
docker compose exec <service> bashOpen a shell in a running service
docker compose run <service> <cmd>Run a one-off command in a new container
docker compose pullPull latest images for all services
docker compose restart <service>Restart a specific service
docker compose configValidate and display the resolved compose config
docker compose up -d --scale web=3Scale a service to 3 replicas
docker loginLog in to Docker Hub (or other registry)
docker login ghcr.ioLog in to GitHub Container Registry
docker logoutLog out from a Docker registry
docker search <term>Search Docker Hub for images
docker pull ghcr.io/owner/image:tagPull from GitHub Container Registry
docker tag app:latest registry.io/app:v1Tag image for a private registry
docker push registry.io/app:v1Push image to a private registry
docker inspect <container>Display detailed container information as JSON
docker inspect --format '{{.State.Status}}' <container>Get specific field from inspect output
docker logs <container>Show container logs
docker logs -f --tail 100 <container>Follow last 100 lines of container logs
docker logs --since 1h <container>Show logs from the last hour
docker top <container>Display running processes in a container
docker statsLive stream of container resource usage
docker stats --no-streamShow resource usage snapshot (no live update)
docker eventsStream real-time events from the Docker daemon
docker diff <container>Show filesystem changes in a container
docker system dfShow Docker disk usage summary
docker system df -vShow detailed disk usage per item
docker system pruneRemove unused containers, networks, and dangling images
docker system prune -a --volumesRemove ALL unused data including volumes
docker image pruneRemove dangling (untagged) images
docker image prune -aRemove all unused images
docker container pruneRemove all stopped containers
docker volume pruneRemove all unused volumes
docker builder pruneRemove build cache
docker infoDisplay system-wide Docker information
docker versionShow Docker client and server version
docker build -t app:latest .Build image from Dockerfile in current directory
docker build -t app:v1 -f Dockerfile.prod .Build using a specific Dockerfile
docker build --no-cache -t app:latest .Build without using layer cache
docker build --build-arg VERSION=1.0 .Build with a build-time variable
docker build --target builder .Build up to a specific multi-stage target
docker buildx build --platform linux/amd64,linux/arm64 -t app .Build multi-platform image
docker buildx create --useCreate and switch to a new buildx builder
docker buildx lsList available buildx builders
docker exec -it <container> bashOpen interactive bash shell in a running container
docker exec -it <container> shOpen shell (for Alpine/minimal images)
docker exec <container> ls /appRun a single command in a container
docker exec -u root <container> apt updateRun command as root user
docker exec -e VAR=value <container> envRun with an additional environment variable
docker attach <container>Attach terminal to a running container's main process
docker cp <container>:/path/file .Copy file from container to host
docker cp file.txt <container>:/path/Copy file from host to container
docker export <container> > backup.tarExport container filesystem as tar archive
docker commit <container> image:tagCreate a new image from a container's changes
Commands shown are for Docker Engine 20+ and Docker Compose v2.
Related Tools
JSON Formatter
Format, validate, and minify JSON data with syntax highlighting
JSON / YAML / TOML Converter
Convert between JSON, YAML, and TOML — validate, format, minify, and download in your browser
Color Scheme Generator
Generate harmonious color palettes — complementary, triadic, analogous, and more
Linux Commands Cheat Sheet
Quick reference for essential Linux commands — files, permissions, networking, and more
Docker Cheat Sheet
A free, searchable Docker cheat sheet with the most useful commands, flags, and shortcuts in one place. Quickly look up syntax, copy commands, and learn Docker containers faster — perfect for beginners and a handy reference for experienced users.
FAQ
- Is this Docker cheat sheet free?
- Yes. The entire cheat sheet is free to browse and copy from, with no sign-up required.
- Can I search for a specific command?
- Yes. Use the search to filter the Docker commands instantly and jump straight to the syntax you need.
- Who is the Docker cheat sheet for?
- It suits everyone from newcomers learning Docker containers to power users who want a quick reminder of less-used flags and shortcuts.