Cheatsheet Docker e Compose
Ciclo di vita dei container, build di immagini, Dockerfile multistadio, stack Compose v2, reti, volumi, log e pulizia sicura su Docker 27+.
Come funziona
Images are immutable layered templates; containers are writable runtime processes from an image; volumes persist state across container replacement; networks wire service DNS.
Kit di sopravvivenza
I pochi comandi da imparare per primi.
42 comandi
Run & Inspect Containers
Start containers, map ports, inspect logs, and attach interactive shells.
- Essenziale
Start an ephemeral interactive container and delete it on exit
docker run --rm -it <image> <shell>Componi il comando
docker run --rm -it <image> <shell>I valori vengono inseriti esattamente come li digiti. Racchiudili tra virgolette se contengono spazi o caratteri speciali.
Quando usarlo
Best for throwaway debugging environments without leaving stopped containers behind.
Dettaglio
- --rm
- Automatically remove container once it exits
- -it
- Interactive stdin (-i) + pseudo-TTY (-t)
Esempio
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.