| Both sides previous revisionPrevious revision | |
| adminsys:docker_cheatsheet [2026/04/29 16:26] – reaton | adminsys:docker_cheatsheet [2026/05/17 12:19] (current) – reaton |
|---|
| |
| ''docker compose up -d'' | ''docker compose up -d'' |
| | |
| | ===== Container Management ===== |
| | A container is a running instance of an image. |
| | |
| | ^ Command ^ Description ^ |
| | | ''docker ps'' | List running containers | |
| | | ''docker ps -a'' | List **all** containers (including stopped ones) | |
| | | ''docker start <id_or_name>'' | Start a stopped container | |
| | | ''docker stop <id_or_name>'' | Gracefully stop a running container | |
| | | ''docker restart <id_or_name>''| Restart a container | |
| | | ''docker rm <id_or_name>'' | Remove a container (must be stopped first) | |
| | | ''docker rm -f <id_or_name>'' | Force removal of a running container | |
| | |
| | ===== Image Management ===== |
| | An image is the blueprint downloaded from Docker Hub. |
| | |
| | ^ Command ^ Description ^ |
| | | ''docker images'' | List all locally stored images | |
| | | ''docker pull <image_name>'' | Download an image from Docker Hub (e.g., ''docker pull nginx'') | |
| | | ''docker rmi <image_id>'' | Remove a local image | |
| | |
| | ===== Troubleshooting & Logs ===== |
| | Essential when a homelab service isn't working as expected. |
| | |
| | ^ Command ^ Description ^ |
| | | ''docker logs <id_or_name>'' | Display container logs | |
| | | ''docker logs -f <id_or_name>'' | Follow logs in real-time (tail -f) | |
| | | ''docker exec -it <id> /bin/bash''| Open an interactive terminal (bash) inside the container | |
| | | ''docker exec -it <id> /bin/sh'' | Open a terminal (sh) if bash is unavailable (common on Alpine) | |
| | | ''docker stats'' | Display live CPU/RAM usage of all containers | |
| | | ''docker inspect <id>'' | Display detailed container info (IP, network, volumes) in JSON format | |
| | | ''docker build -t <name> .'' | Build an image from the Dockerfile in the current directory | |
| | |
| | |
| | ===== Cleanup (Prune) ===== |
| | To free up disk space on the server. **Use these commands with caution!** |
| | |
| | ^ Command ^ Description ^ |
| | | ''docker container prune'' | Remove all stopped containers | |
| | | ''docker image prune'' | Remove dangling images (no tags, not associated with a container) | |
| | | ''docker volume prune'' | Remove unused volumes (risk of data loss) | |
| | | ''docker system prune -a'' | Deep clean: remove everything that is not currently in use | |
| | |
| | ===== Docker Compose ===== |
| | To manage multi-container stacks (via a ''docker-compose.yml'' file). |
| | |
| | ^ Command ^ Description ^ |
| | | ''docker compose up -d'' | Create and start containers in the background (detached mode) | |
| | | ''docker compose down'' | Stop and remove containers and networks defined in the stack | |
| | | ''docker compose pull'' | Pull the latest images defined in the compose file | |
| | | ''docker compose logs -f'' | Follow logs for the entire stack in real-time | |