Carles Andres' avatarHomeBlogReferenceCheatsheets
All cheatsheets

Most Useful Docker Commands

Practical Docker command reference for everyday container work, builds, cleanup, and debugging; anchors are commands intended to render as code.

Published on 3/23/2026

Getting Started

Beginner-friendly commands for checking your setup, pulling images, and starting containers.

CommandDescriptionDetailsSource
docker versionShow client and server version details to confirm the CLI can talk to the Docker daemon.-
docker infoInspect daemon configuration, storage driver, contexts, and runtime details when troubleshooting your setup.-
docker pull <image>Download an image from a registry before running it or to refresh a local copy.-
docker run --rm -it <image> shStart an interactive disposable container shell for quick testing, exploration, or debugging.
docker psList running containers so you can inspect names, status, ports, and image tags.-
docker imagesList local images available for running, tagging, or deleting.-

Containers And Logs

Daily commands for listing containers, entering shells, reading logs, and cleaning up stopped containers.

CommandDescriptionDetailsSource
docker container ls -aShow both running and stopped containers when you need full history instead of only active ones.-
docker logs -f <container>Stream container output in real time to watch startup, requests, errors, or crashes.
docker exec -it <container> shOpen an interactive shell inside a running container without restarting it.
docker stop <container>Gracefully stop a running container by sending the configured stop signal.-
docker rm <container>Remove a stopped container you no longer need to keep your local environment tidy.-
docker inspect <container>Return low-level JSON for ports, mounts, networks, environment, and other runtime details.

Images And Builds

Core image workflow plus more advanced Buildx commands for modern multi-platform builds.

CommandDescriptionDetailsSource
docker build -t <name> .Build an image from the current directory and tag it so it is easy to run later.-
docker tag <image> <repo>:<tag>Create a new image reference before pushing to a registry or publishing a release tag.-
docker push <repo>:<tag>Upload a tagged image to a registry so other machines or deployments can pull it.-
docker image history <image>Review image layers to understand size growth and what each build step added.-
docker buildx build --platform linux/amd64,linux/arm64 --push .Build and publish a multi-platform image for common x86 and ARM deployment targets.
docker buildx build --secret id=<name>,src=<file> .Pass build-time secrets without baking credentials into final image layers.

Cleanup And Troubleshooting

Commands for reclaiming disk space, watching resource usage, and tracing Docker activity.

CommandDescriptionDetailsSource
docker system dfShow how much disk space images, containers, volumes, and build cache are using.-
docker system pruneRemove unused containers, networks, dangling images, and build cache to free space quickly.
docker image prune -aDelete unused images that are not attached to any container when disk usage grows.-
docker container pruneRemove all stopped containers in one step instead of deleting them individually.-
docker statsWatch live CPU, memory, network, and block I/O usage for running containers.
docker eventsStream real-time daemon events to trace container lifecycle actions and debug odd behavior.