Docker Compose Tip #28: Converting docker run commands to Compose

Stop managing long docker run commands! Convert them to maintainable Compose files. Basic conversions Common flag mappings: # Docker run command docker run -d \ --name myapp \ -p 3000:3000 \ -e NODE_ENV=production \ -e API_KEY=secret123 \ -v $(pwd)/data:/app/data \ -v /var/run/docker.sock:/var/run/docker.sock \ --restart unless-stopped \ myapp:latest Becomes: services: myapp: image: myapp:latest container_name: myapp ports: - "3000:3000" environment: NODE_ENV: production API_KEY: secret123 volumes: - ./data:/app/data - /var/run/docker.sock:/var/run/docker.sock restart: unless-stopped Network configurations # Host network docker run --network host nginx # Custom network docker run --network mynet --ip 172.20.0.5 app # Network alias docker run --network mynet --network-alias db postgres Compose equivalent: ...

February 11, 2026 · 3 min · 508 words · Guillaume Lours

Docker Compose Tip #20: Using docker compose logs effectively

Stop scrolling through endless output. Master docker compose logs options to find issues fast and monitor services effectively. Basic commands # All service logs docker compose logs # Single service docker compose logs web # Multiple services docker compose logs web worker Follow logs in real-time Watch logs as they happen: # Follow all services docker compose logs -f # Follow specific service docker compose logs -f api # Start fresh and follow docker compose logs -f --since 1m Tail recent logs Get last N lines: ...

January 30, 2026 · 3 min · 427 words · Guillaume Lours

Docker Compose Tip #19: Override files for local development

Keep production and development configs separate. Docker Compose automatically merges compose.override.yml for local development tweaks. The magic Compose automatically loads two files: compose.yml (base configuration) compose.override.yml (local overrides) # These are equivalent: docker compose up docker compose -f compose.yml -f compose.override.yml up Basic setup compose.yml (production-ready): services: web: image: myapp:latest ports: - "80:80" environment: NODE_ENV: production LOG_LEVEL: warn compose.override.yml (developer-friendly): services: web: build: . # Build locally instead of using image ports: - "3000:80" # Different port for development volumes: - .:/app # Mount source code environment: NODE_ENV: development LOG_LEVEL: debug DEBUG: "true" Real development example compose.yml: ...

January 29, 2026 · 2 min · 348 words · Guillaume Lours

Docker Compose Tip #5: Writing Compose files for AI tools

AI tools work better when they understand the setup. Here’s how to document Compose files effectively. Add context with comments Comments help AI understand what each service does: services: # Primary web application serving React frontend # Handles user authentication and API gateway web: image: myapp:latest ports: - "3000:3000" # Public facing port - update in .env for production environment: # Connection string to PostgreSQL - format: postgresql://user:pass@host:5432/db DATABASE_URL: ${DATABASE_URL} # JWT secret for auth - must be at least 256 bits JWT_SECRET: ${JWT_SECRET} depends_on: db: condition: service_healthy # Development only - remove for production volumes: - ./src:/app/src # Hot reload for development # PostgreSQL 15 database with PostGIS extension # Stores user data and geographic information db: image: postgis/postgis:15-3.3 environment: POSTGRES_DB: myapp POSTGRES_PASSWORD: ${DB_PASSWORD} # Never commit actual password volumes: # Initial schema and seed data - ./init.sql:/docker-entrypoint-initdb.d/01-init.sql # Persistent data storage - postgres_data:/var/lib/postgresql/data volumes: postgres_data: # Named volume for database persistence across container restarts File headers For bigger projects, add a header: ...

January 9, 2026 · 3 min · 436 words · Guillaume Lours

Docker Compose Tip #1: Debug your configuration with config

When your Compose setup gets complex, docker compose config becomes your best debugging tool. Especially with profiles. The basics docker compose config This shows you the actual configuration that Docker Compose will run: Environment variables are replaced with their values Relative paths become absolute Default values are applied Multiple compose files are merged YAML anchors are resolved What you write: services: web: image: myapp:${VERSION:-latest} volumes: - ./data:/app/data environment: DATABASE_URL: ${DATABASE_URL} What docker compose config shows you: ...

January 5, 2026 · 2 min · 401 words · Guillaume Lours