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 #27: Extension fields as metadata for tools and platforms

Extension fields aren’t just for YAML reusability - they’re powerful metadata carriers that tools can leverage for platform-specific configurations! Extension fields as metadata Any key starting with x- is ignored by Compose but preserved in the configuration: # Top-level metadata x-project-version: "2.1.0" x-team: "platform-engineering" x-environment: "production" x-region: "us-east-1" services: api: image: myapi:latest # Service-level metadata x-tier: "frontend" x-cost-center: "engineering" x-sla: "99.9" x-owner: "api-team@company.com" Compose Bridge and Kubernetes integration Extension fields can provide hints for Kubernetes deployment: ...

February 10, 2026 · 3 min · 470 words · Guillaume Lours

Docker Compose Tip #26: Using restart policies effectively

Keep your services running! Restart policies ensure containers recover from crashes automatically. Available restart policies Docker Compose offers four restart options: services: # Never restart (default) dev-tool: image: debug-tools restart: "no" # Restart only on failure (non-zero exit) api: image: api:latest restart: on-failure # Always restart unless manually stopped web: image: nginx restart: unless-stopped # Always restart, even after Docker daemon restarts database: image: postgres:15 restart: always Choosing the right policy Development services: ...

February 9, 2026 · 2 min · 346 words · Guillaume Lours

Docker Compose Tip #25: Using docker compose events for monitoring

Track everything happening in your Compose stack! Events provide real-time insights into container lifecycle changes. Basic event monitoring Watch events as they happen: # Stream all events docker compose events # JSON format for parsing docker compose events --json # Specific services only docker compose events web worker # Since a specific time docker compose events --since "2026-02-06T10:00:00" Event types Common events you’ll see: container create # Container created container start # Container started container stop # Stop initiated container die # Container exited container destroy # Container removed health_status # Health check changed network connect # Network attached network disconnect # Network detached Processing events Parse with jq: ...

February 6, 2026 · 3 min · 555 words · Guillaume Lours

Docker Compose Tip #24: Using profiles to organize optional services

Keep your Compose stack flexible! Profiles let you include or exclude services based on your current needs. Basic profiles Define optional services with profiles: services: app: image: myapp:latest ports: - "3000:3000" # No profile - always starts debug: image: debug-tools profiles: - debug # Only starts with --profile debug test-db: image: postgres:15 profiles: - test environment: POSTGRES_DB: test_db Starting with profiles Choose which services to include: ...

February 5, 2026 · 2 min · 376 words · Guillaume Lours