Docker Compose Tip #66: Volume drivers with NFS

Compose volumes default to local disk on the host running the container. When you need storage shared across hosts, a volume driver does the job. The built-in local driver already supports NFS through its options. Basic NFS mount Declare a volume that points to an NFS export: volumes: shared: driver: local driver_opts: type: nfs o: "addr=nfs-server.example.com,rw,nfsvers=4" device: ":/exports/shared" services: app: image: myapp volumes: - shared:/data The app service mounts /exports/shared from the NFS server at /data inside the container. Multiple containers (or even multiple Compose stacks on different hosts) can mount the same volume to share data. ...

May 22, 2026 · 3 min · 446 words · Guillaume Lours

Docker Compose Tip #65: Custom DNS configuration with dns and dns_search

By default, containers inherit DNS configuration from the Docker daemon. When you need to override that, three directives give you full control: dns:, dns_search:, and dns_opt:. Setting custom DNS servers dns: overrides which resolvers the container queries: services: app: image: myapp dns: - 1.1.1.1 - 8.8.8.8 The container now uses Cloudflare and Google DNS instead of whatever the host provides. Useful when: The host DNS is slow or unreliable for your use case You need a specific public DNS for content filtering (Pi-hole, NextDNS) A development environment must reach internal services through a corporate DNS server Search domains dns_search: adds search domains so short names resolve against them: ...

May 20, 2026 · 2 min · 407 words · Guillaume Lours

Docker Compose Tip #62: Network aliases for service routing

By default, services in Compose are reachable by their service name. With aliases, you can give a service additional hostnames on a network, no extra DNS config required. Basic usage Add aliases under the network attachment: services: primary: image: postgres networks: app-net: aliases: - db - database - postgres-primary networks: app-net: From any other container on app-net, you can reach the service as primary, db, database, or postgres-primary. All four hostnames resolve to the same container. ...

May 13, 2026 · 2 min · 404 words · Guillaume Lours

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