Docker Compose Tip #54: Preview changes with --dry-run

Not sure what docker compose up will actually do? Add --dry-run to preview every action without executing anything. Basic usage docker compose up --dry-run Compose shows exactly what it would do: DRY-RUN MODE - Container myapp-db-1 Creating DRY-RUN MODE - Container myapp-db-1 Created DRY-RUN MODE - Container myapp-web-1 Creating DRY-RUN MODE - Container myapp-web-1 Created DRY-RUN MODE - Container myapp-db-1 Starting DRY-RUN MODE - Container myapp-db-1 Started DRY-RUN MODE - Container myapp-web-1 Starting DRY-RUN MODE - Container myapp-web-1 Started Nothing is created, started, or modified. You just see the plan. ...

April 17, 2026 · 2 min · 380 words · Guillaume Lours

Docker Compose Tip #53: Compose project name and working directory

Every Compose stack gets a project name. It prefixes all resource names such as containers, networks, volumes. Understanding how it works avoids naming conflicts and makes multi-environment setups cleaner. Default behavior By default, the project name is the directory name where your compose.yml lives: my-app/ compose.yml docker compose up -d # Creates: my-app-web-1, my-app-db-1, my-app_default network Setting the project name Three ways to set it, in order of precedence: # 1. CLI flag (highest precedence) docker compose -p myproject up # 2. Environment variable COMPOSE_PROJECT_NAME=myproject docker compose up # 3. In the Compose file itself # compose.yml name: myproject services: web: image: nginx The name key in the Compose file is the recommended approach, it’s versioned with your code and everyone on the team gets the same project name. ...

April 15, 2026 · 2 min · 385 words · Guillaume Lours

Docker Compose Tip #51: docker compose up --wait for scripting and CI

docker compose up -d starts services in the background, but it returns immediately — before services are actually ready. --wait solves this by blocking until all services are healthy. The problem Without --wait, you often end up with fragile sleep-based scripts: # Fragile: how long is enough? docker compose up -d sleep 10 npm test The solution docker compose up --wait npm test --wait starts services in detached mode and blocks until every service with a healthcheck reports healthy. If a service fails to become healthy, the command exits with a non-zero status. ...

April 10, 2026 · 2 min · 354 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 #42: Variable substitution and defaults

Docker Compose supports shell-style variable substitution in your Compose files. Combined with defaults and error messages, it makes your configurations flexible and safe. Basic substitution Reference environment variables or .env file values: services: app: image: myapp:${TAG} environment: DATABASE_URL: postgres://${DB_USER}:${DB_PASS}@db/${DB_NAME} # .env TAG=2.1.0 DB_USER=admin DB_PASS=secret DB_NAME=myapp Default values Provide fallback values when a variable is unset or empty: services: app: image: myapp:${TAG:-latest} environment: LOG_LEVEL: ${LOG_LEVEL:-info} PORT: ${PORT:-3000} deploy: replicas: ${REPLICAS:-1} Two syntaxes with a subtle difference: ...

March 20, 2026 · 2 min · 417 words · Guillaume Lours