Docker CLI Cheat Sheet: Every Command You Use Daily
Every Docker CLI command and the flags you actually use, in one reference.
Containers, images, volumes, and cleanup - the docker CLI essentials.
Containers
| Command | Does |
|---|
| docker run --rm -it img sh | Run interactively, auto-remove |
| docker run -d -p 8080:80 img | Detached, publish port |
| docker ps -a | List all containers |
| docker exec -it id sh | Shell into running container |
| docker logs -f id | Follow logs |
| docker stop / rm id | Stop / remove |
| docker cp id:/path ./local | Copy file out |
Images
| Command | Does |
|---|
| docker build -t name:tag . | Build image |
| docker images | List images |
| docker pull / push name | Pull / push registry |
| docker tag src dst | Re-tag |
| docker rmi name | Remove image |
| docker history name | Inspect layers |
Volumes & networks
| Command | Does |
|---|
| docker volume ls / create | List / create volumes |
| docker run -v vol:/data img | Mount named volume |
| docker run -v $PWD:/app img | Bind-mount cwd |
| docker network ls / create | List / create networks |
Cleanup
| Command | Reclaims |
|---|
| docker system prune -af | Stopped containers, dangling images |
| docker system prune -af --volumes | Above + unused volumes |
| docker image prune -a | Unused images |
| docker builder prune | Build cache |
Key takeaways
- --rm avoids piling up stopped containers in CI.
- system prune -af --volumes is the safe CI disk reclaimer.
- Bind-mount with $PWD for live local dev; named volumes for persistence.
Related guides
Docker Cheat Sheet: Commands, Dockerfile & ComposeA Docker cheat sheet - build, run, images, volumes, networks, Dockerfile instructions, and compose commands f…
Dockerfile Instructions Cheat Sheet: Every Keyword ExplainedA Dockerfile instructions cheat sheet - FROM, RUN, COPY, ENV, ARG, ENTRYPOINT, CMD, HEALTHCHECK, and multi-st…
Docker Compose Cheat Sheet: Commands & compose.yaml KeysA docker compose cheat sheet - up, down, build, logs, exec commands plus the compose.yaml service keys you co…