🧹 Self-Cleaning Containers
500 stopped containers eating disk space? One flag prevents this.
# Auto-delete after stop docker run --rm -it ubuntu bash # Without --rm (default) docker run -it ubuntu bash # Container stays after exit (uses disk space) # Clean existing stopped containers docker container prune -f
When to Use –rm: Testing, one-off commands, CI/CD builds.
When NOT to Use: Production containers you might need to inspect logs from.
Saved Space: 10-50 MB per stopped container × 500 = 5-25 GB!
