Docker Compose Tip #38: When to use include vs extends vs overrides

Now that you understand how include, extends, and override files work, how do you pick the right one? Here’s a practical guide. Use override files for environment-specific configuration Override files are the right choice when you need to adapt the same stack to different environments or developer setups: # compose.yml - base definition, committed to git services: app: image: myapp:${TAG:-latest} environment: NODE_ENV: production # compose.override.yml - local dev tweaks, optionally gitignored services: app: build: . # Build locally instead of pulling image environment: NODE_ENV: development volumes: - .:/app # Mount source for hot reload Good fit for: ...

March 11, 2026 · 2 min · 342 words · Guillaume Lours

Docker Compose Tip #37: Understanding include, extends, and override files

Docker Compose gives you three ways to split and reuse configurations. They look similar but work at different levels and serve different purposes. Override files: project-level merge Override files are merged with your main compose.yml at the project level. compose.override.yml is loaded automatically; additional files require the -f flag: # compose.override.yml is loaded automatically docker compose up # Explicit merge docker compose -f compose.yml -f compose.prod.yml up Mappings are merged (override wins), arrays are concatenated: ...

March 9, 2026 · 2 min · 335 words · Guillaume Lours

Docker Compose Tip #36: Using extra_hosts for custom DNS entries

Need custom DNS resolution in containers? Use extra_hosts to add hostname mappings without touching system files! Basic extra_hosts usage Add custom host entries to containers: services: app: image: myapp extra_hosts: - "api.local:192.168.1.100" - "db.local:192.168.1.101" - "cache.local:192.168.1.102" Inside the container: docker compose exec app cat /etc/hosts # 127.0.0.1 localhost # 192.168.1.100 api.local # 192.168.1.101 db.local # 192.168.1.102 cache.local Dynamic host resolution Use host machine’s IP dynamically: services: app: image: myapp extra_hosts: - "host.docker.internal:host-gateway" # Magic value! This maps to: ...

March 6, 2026 · 3 min · 441 words · Guillaume Lours

Docker Compose Tip #35: Using tmpfs for ephemeral storage

Speed up I/O operations and enhance security by using tmpfs for temporary data. RAM-based storage that vanishes on restart! What is tmpfs? Tmpfs is a temporary filesystem that resides in memory: ⚡ Ultra-fast (RAM speed) 🔒 Secure (data doesn’t persist) 🧹 Self-cleaning (cleared on restart) Basic tmpfs usage Simple tmpfs mount: services: app: image: myapp tmpfs: - /tmp - /app/cache - /var/run With size limits: services: app: image: myapp tmpfs: - /tmp:size=100M - /app/cache:size=500M - /var/run:size=10M Advanced tmpfs options Fine-tuned configuration: ...

March 4, 2026 · 3 min · 524 words · Guillaume Lours

Docker Compose Tip #34: Debugging with exec vs run

Know the difference between exec and run! Each has its place in your debugging toolkit. The key difference exec: Runs commands in an existing container run: Creates a new container # Exec: enters running container docker compose exec web bash # Run: starts new container docker compose run web bash When to use exec Use exec for debugging running services: # Debug a running web server docker compose exec web bash # Check logs inside container docker compose exec web tail -f /var/log/app.log # Run database queries docker compose exec db psql -U postgres # Check process list docker compose exec web ps aux # Test connectivity from inside docker compose exec web curl http://api:3000/health Important: Container must be running! ...

March 2, 2026 · 3 min · 636 words · Guillaume Lours