The Complete Docker CLI, Compose & Container Reference Card
Quick copy-paste syntax for container lifecycles, debugging running pods, pruning dangling volumes, and multi-stage builds.
Table of Contents
Container Lifecycle Commands
Creating, executing, and managing containerized applications.
| Task | Command Syntax | Purpose |
|---|---|---|
| Run in Background | `docker run -d -p 8080:80 --name web nginx` | Starts container detached, forwarding host port 8080 to container port 80. |
| Interactive Shell | `docker exec -it web /bin/sh` | Opens interactive terminal session inside a running container. |
| Follow Logs | `docker logs -f --tail 100 web` | Streams last 100 log lines and continues watching live output. |
| Restart Policy | `docker run -d --restart unless-stopped app` | Ensures container restarts automatically after host reboot or crash. |
Disk Cleanup & Pruning
Reclaiming gigabytes of disk space from stale layers and dangling volumes.
| Cleanup Operation | Command Syntax | What It Removes |
|---|---|---|
| System Prune (All) | `docker system prune -af --volumes` | Removes all stopped containers, unused networks, unreferenced images, and build cache. |
| Dangling Images Only | `docker image prune` | Removes untagged `<none>:<none>` intermediate build layers. |
| Orphaned Volumes | `docker volume prune` | Deletes persistent volumes not mounted by any existing container. |
Interactive Client-Side Tools for this Guide
Test and run these patterns directly inside your browser with zero server uploads:
Linux Chmod Permissions Calculator & Command Generator
Calculate numerical and symbolic Linux file permissions with an interactive permission matrix. Generate terminal commands without memorizing octal values.
Online Cron Expression Generator & Human Explainer
Build cron schedule strings interactively or translate cryptic expressions into plain English. View next estimated runtimes with zero server latency.
Frequently Asked Questions
What is the difference between docker stop and docker kill?
docker stop sends SIGTERM and waits a grace period (10 seconds) for graceful process exit before sending SIGKILL. docker kill sends SIGKILL immediately.
Why do Docker images accumulate so much disk space?
Docker caches every instruction layer from Dockerfile builds. Over months of CI/CD builds, dangling intermediate layers consume tens of gigabytes unless pruned.