Docker & Compose-Cheatsheet
Container-Lebenszyklus, Image-Builds, Multi-Stage-Dockerfiles, Compose-v2-Stacks, Netzwerke, Volumes, Logs und sichere Aufräumbefehle für Docker 27+.
Funktionsweise
Images are immutable layered templates; containers are writable runtime processes from an image; volumes persist state across container replacement; networks wire service DNS.
Survival-Kit
Die wichtigsten Befehle für den Einstieg.
42 Befehle
Run & Inspect Containers
Start containers, map ports, inspect logs, and attach interactive shells.
- Grundlagen
Start an ephemeral interactive container and delete it on exit
docker run --rm -it <image> <shell>Befehl zusammenbauen
docker run --rm -it <image> <shell>Werte werden genau wie eingegeben eingefügt. Setze sie selbst in Anführungszeichen, falls sie Leer- oder Sonderzeichen enthalten.
Wann verwenden
Best for throwaway debugging environments without leaving stopped containers behind.
Aufbau
- --rm
- Automatically remove container once it exits
- -it
- Interactive stdin (-i) + pseudo-TTY (-t)
Beispiel
docker run --rm -it alpine:3.20 sh
Images & Multi-Platform Builds
Build, tag, inspect image layers, and manage local registries.
Docker Compose v2
Orchestrate multi-container local stacks cleanly with `docker compose`.
Volumes, Networks & Files
Persist database state, connect containers by service name, and copy files.
Disk Usage & Safe Cleanup
Measure disk consumption and prune unused objects without losing data.