Docker Compose file · Profiles, development and reuse

Avoid repetition with anchors

Define settings once and reuse them in several services.

x-common: &common
  restart: unless-stopped
  logging:
    driver: json-file
    options:
      max-size: "10m"

services:
  web:
    <<: *common
    image: web:1.0
  worker:
    <<: *common
    image: worker:1.0

Official Docker Compose file documentation

More profiles, development and reuse commands

All profiles, development and reuse commands · Docker Compose file cheatsheet

Was this page helpful?