Docker Compose Tip #48: Network debugging with docker compose port

When using dynamic port mapping or multiple services, it’s not always obvious which host port maps to which container port. docker compose port tells you exactly. Basic usage # Which host port maps to container port 80 on the web service? docker compose port web 80 # Output: 0.0.0.0:8080 Why dynamic ports matter When you let Docker assign ports automatically, the host port changes on every docker compose up: services: web: image: nginx ports: - "80" # Dynamic host port, container port 80 docker compose port web 80 # Output: 0.0.0.0:55432 (assigned dynamically) This is common in CI or when running multiple instances of the same project. ...

April 3, 2026 · 2 min · 320 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 #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

Docker Compose Tip #21: Understanding bridge vs host networking modes

Choose the right networking mode for your containers. Understand when isolation matters and when performance is key. Bridge mode (default) The default and most secure option - containers get their own network namespace: services: web: image: nginx ports: - "8080:80" # Port mapping required networks: - app_network db: image: postgres:15 networks: - app_network networks: app_network: driver: bridge Containers can communicate using service names (web, db) within the network. ...

February 2, 2026 · 2 min · 330 words · Guillaume Lours

Docker Compose Tip #13: Using external networks to connect multiple projects

Need your frontend project to talk to a backend in another Compose project? External networks let you connect containers across different stacks. The problem Two separate Compose projects need to communicate: frontend/compose.yml - React app backend/compose.yml - API service By default, each creates its own isolated network. The solution Create a shared external network: # Create the network once docker network create shared-network Then reference it in both projects: backend/compose.yml: ...

January 21, 2026 · 2 min · 308 words · Guillaume Lours