You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Start all services in detached mode (background)
docker compose up -d
# Start specific service(s)
docker compose up -d postgres kafka
# Start and view logs (foreground)
docker compose up
# Start and rebuild images
docker compose up -d --build
Stopping Services
# Stop all running services (keeps containers)
docker compose stop
# Stop specific service
docker compose stop postgres
# Stop and remove containers (data persists in volumes)
docker compose down
# Stop and remove containers + volumes (DELETES ALL DATA!)
docker compose down -v
# Stop and remove containers + images
docker compose down --rmi all
Viewing Status & Logs
# List all services and their status
docker compose ps
# View logs of all services
docker compose logs
# Follow logs in real-time
docker compose logs -f
# View logs for specific service
docker compose logs postgres
docker compose logs -f kafka
# View last 100 lines
docker compose logs --tail=100
# View logs with timestamps
docker compose logs -t
Restarting Services
# Restart all services
docker compose restart
# Restart specific service
docker compose restart postgres
# Restart and view logs
docker compose restart postgres && docker compose logs -f postgres
Executing Commands in Containers
# Execute command in running container
docker compose exec postgres psql -U taskuser -d taskdb
# Execute as specific user
docker compose exec -u root postgres bash
# Start a bash shell in container
docker compose exec postgres bash
docker compose exec kafka bash
# Run one-off command (creates new container)
docker compose run postgres psql -U taskuser
Service Management
Building & Pulling
# Build or rebuild services
docker compose build
# Build specific service
docker compose build task-service
# Pull latest images
docker compose pull
# Build without cache
docker compose build --no-cache
Scaling Services
# Scale a service to multiple instances
docker compose up -d --scale kafka=3
# Scale multiple services
docker compose up -d --scale web=3 --scale worker=2
Configuration
# Validate docker-compose.yml syntax
docker compose config
# View the actual configuration (with variable substitution)
docker compose config --resolve-image-digests
# List services defined in compose file
docker compose config --services
Volume & Network Management
Volumes
# List volumes
docker volume ls
# Inspect a volume
docker volume inspect taskmanagement_postgres_data
# Remove unused volumes
docker volume prune
# Remove specific volume (service must be stopped)
docker volume rm taskmanagement_postgres_data
Networks
# List networks
docker network ls
# Inspect network
docker network inspect taskmanagement_app-network
# Remove unused networks
docker network prune
Troubleshooting
Health Checks
# Check container health status
docker compose ps
# Inspect container details
docker inspect task-postgres
# View health check logs
docker inspect task-postgres | grep -i health
Resource Usage
# View resource usage (CPU, Memory)
docker stats
# View for specific service
docker stats task-postgres
Debugging
# View container processes
docker compose top
# View port mappings
docker compose port postgres 5432
# Check events
docker compose events
# Pause all services
docker compose pause
# Unpause all services
docker compose unpause
Clean Up Commands
Remove Everything (Nuclear Option)
# Stop and remove containers, networks
docker compose down
# Stop and remove containers, networks, volumes
docker compose down -v
# Stop and remove containers, networks, volumes, images
docker compose down -v --rmi all
# Remove all unused Docker resources system-wide
docker system prune -a --volumes