Docker Compose Tip #7: Restarting single services without stopping the stack

Stop doing docker compose down && docker compose up for every code change. Docker Compose lets you restart individual services while keeping the rest running. The solution Restart just what changed: # Restart only the web service docker compose up -d web # Your database, cache, and queue keep running! This simple command saves minutes per restart. Your database keeps its data, Redis maintains its cache, message queues preserve their state. ...

January 13, 2026 · 3 min · 439 words · Guillaume Lours

Docker Compose Tip #6: Service discovery and internal DNS

Hardcoding IP addresses in your containers? Docker Compose provides automatic DNS-based service discovery. Each service can reach another using just the service name. How it works Docker Compose creates a default network and registers each container with an internal DNS server. The DNS name matches the service name in your compose.yml. services: web: image: nginx environment: # Just use the service name! API_URL: http://api:3000 DB_HOST: postgres api: image: myapi environment: DATABASE_URL: postgres://user:pass@postgres:5432/mydb postgres: image: postgres:15 No configuration needed. The web service connects to api using http://api:3000, and api connects to postgres using the hostname postgres. ...

January 12, 2026 · 2 min · 344 words · Guillaume Lours

Docker Compose Tip #3: Service dependencies with health checks

“Connection refused” errors? The app starts before the database is ready. Here’s the fix. What doesn’t work This only waits for the container to start, not for it to be ready: services: app: depends_on: - db # Container starts, but database isn't ready yet What actually works Add health checks: services: db: image: postgres:16 environment: POSTGRES_PASSWORD: secret healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 10s timeout: 5s retries: 5 start_period: 10s app: image: myapp depends_on: db: condition: service_healthy # Now it actually waits for the database Common health checks PostgreSQL: ...

January 7, 2026 · 2 min · 239 words · Guillaume Lours

Docker Compose Tip #2: Using --env-file for different environments

Same compose.yml, different environments. Here’s the cleanest approach. Basic setup Create different env files for each environment: .env.dev DATABASE_URL=postgresql://localhost:5432/dev_db API_KEY=dev_key_12345 LOG_LEVEL=debug REPLICAS=1 .env.prod DATABASE_URL=postgresql://prod-db.example.com:5432/prod_db API_KEY=${SECURE_API_KEY} # From CI/CD secrets LOG_LEVEL=error REPLICAS=3 How to use them # Development docker compose --env-file .env.dev up # Production docker compose --env-file .env.prod up # Override specific vars API_KEY=test_key docker compose --env-file .env.dev up Layering configs You can use multiple env files: # Base + environment-specific docker compose \ --env-file .env.base \ --env-file .env.prod \ up Note: Later files override earlier ones. ...

January 6, 2026 · 1 min · 175 words · Guillaume Lours