Complete Docker commands cheat sheet for container management, image operations, Docker Compose, and system administration. Essential reference for DevOps engineers and developers working with containerized applications.
Search all Docker shortcuts interactively
Interactive Shortcut Finder| Shortcut | Action | Description |
|---|---|---|
| docker run [image] | Run container | Create and start a new container. |
| docker ps | List running | List currently running containers. |
| docker ps -a | List all | List all containers including stopped. |
| docker stop [ID] | Stop container | Stop a running container. |
| docker rm [ID] | Remove container | Remove a stopped container. |
| docker exec -it [ID] bash | Enter container | Open a bash shell inside a running container. |
| docker logs [ID] | View logs | View container logs. |
| docker restart [ID] | Restart | Restart a container. |
| Shortcut | Action | Description |
|---|---|---|
| docker images | List images | List locally stored images. |
| docker pull [image] | Pull image | Download an image from Docker Hub. |
| docker build -t [tag] . | Build image | Build an image from a Dockerfile. |
| docker rmi [image] | Remove image | Remove a local image. |
| docker push [image] | Push image | Push an image to a registry. |
| docker tag [src] [dst] | Tag image | Assign a new tag to an image. |
| Shortcut | Action | Description |
|---|---|---|
| docker compose up -d | Start services | Start all services in the background. |
| docker compose down | Stop services | Stop and remove all service containers. |
| docker compose logs -f | Follow logs | Follow service logs in real time. |
| docker compose ps | Service status | Check service status. |
| docker compose build | Build services | Build service images. |
| docker compose restart | Restart | Restart all services. |
| Shortcut | Action | Description |
|---|---|---|
| docker system prune | Cleanup | Remove unused containers, images, and networks. |
| docker volume ls | List volumes | List Docker volumes. |
| docker network ls | List networks | List Docker networks. |
| docker stats | Resource usage | Show real-time CPU and memory usage per container. |
Browse shortcuts for 269 platforms
Explore AllMost Docker days are run, ps, logs, exec. docker run creates and starts a container from an image; docker ps shows what's running and -a adds the stopped ones — which matters because a crashed container disappears from plain ps and beginners conclude it never started. docker logs -f follows output, and docker exec -it <id> bash drops you inside a running container (swap sh for minimal images that lack bash).
Since Compose v2 the command is docker compose — a space, not the old hyphenated docker-compose binary. up -d starts the stack detached, logs -f tails every service together, and down stops and removes containers and networks (volumes survive unless you add -v). The pairing worth internalizing: edit a Dockerfile → docker compose build → up -d recreates only what changed.
Docker hoards: stopped containers, dangling images, and build cache accumulate for weeks until the disk fills. docker system prune clears stopped containers, unused networks, and dangling images in one shot — but read its prompt before confirming, and know that adding -a also removes every image not used by a running container, which means long re-pulls later. docker stats and docker volume ls answer the two questions that precede most cleanups: what's eating resources, and what data would I lose?
run creates a new container from an image and starts it; exec runs an extra process (usually a shell) inside a container that's already running.
Plain ps lists running containers only. If it exited or crashed, docker ps -a shows it with its exit status, and docker logs <id> shows why.
docker compose (space) is the current v2 syntax built into the CLI. The hyphenated docker-compose is the legacy v1 binary; commands are otherwise near-identical.
It removes containers and networks but keeps named volumes. Add -v only when you deliberately want volumes gone too.
It only removes stopped containers, unused networks, and dangling images — running workloads are untouched. The riskier variant is prune -a, which also deletes all unused images.
Open your assistant with this page preloaded as the source — great for follow-up questions like "which of these work in other apps?"