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 #33: Using logging drivers and options

Take control of your container logs! Configure different logging drivers for better management, rotation, and analysis. Default logging: json-file By default, Docker uses the json-file driver: services: app: image: myapp logging: driver: json-file options: max-size: "10m" # Rotate after 10MB max-file: "3" # Keep 3 rotated files compress: "true" # Compress rotated files Without rotation, logs can fill your disk! Common logging drivers 1. Local driver (efficient storage) Optimized for performance and disk usage: ...

February 27, 2026 · 3 min · 536 words · Guillaume Lours

Docker Compose Tip #32: Build contexts and dockerignore patterns

Speed up builds and reduce image size by managing build contexts effectively. Don’t send unnecessary files to the Docker daemon! Understanding build context The build context is what gets sent to Docker daemon: services: app: build: . # Current directory is the context # Everything in . gets sent to daemon! Check your context size: # See what's being sent docker build --no-cache . 2>&1 | grep "Sending build context" # Output: Sending build context to Docker daemon 458.2MB 😱 Custom build contexts Specify different contexts for different services: ...

February 25, 2026 · 3 min · 433 words · Guillaume Lours

Docker Compose Tip #31: Network isolation between services

Secure your application architecture by isolating services in separate networks. Not every service needs to talk to every other service! Default behavior: All connected By default, all services share the same network: # All services can communicate services: web: image: nginx api: image: myapi database: image: postgres Problem: web can directly access database - potential security risk! Network isolation pattern Create separate networks for different tiers: ...

February 23, 2026 · 3 min · 516 words · Guillaume Lours