← Back to All Cheatsheets
DevOps & Containers

🐳 Docker & Docker Compose Production Reference

Complete guide to container lifecycle management, multi-stage builds, volume persistence, and network inspection.

1. Container Lifecycle Commands

# Build Image & Start Stack in Background
docker-compose up -d --build

# Interactive Shell inside Container
docker exec -it <container_id_or_name> /bin/bash

# Real-Time Log Streaming
docker logs -f --tail 100 <container_name>

2. Pruning & Resource Cleanup

# Remove All Unused Containers, Networks & Images
docker system prune -a --volumes -f

# Inspect Container Resource Usage (CPU, Memory, I/O)
docker stats
Support My Work