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
- Make services optional
- Sync or rebuild on file changes
- Override settings for development
- Include another Compose file
All profiles, development and reuse commands · Docker Compose file cheatsheet