The Compose specification declaratively models a multi-container application: its services, configuration, networks, and relationships. The same specification works with Windows and Linux containers. section 13.4
A service definition identifies an image and its settings. Networks connect the services, while depends_on can delay application startup until a database health check reports readiness. section 13.4
Nerd Dinner application
A web service and SQL Server database share the nd-net network. The database writes an initialization marker after deployment; the web service waits for the database health check before starting. Run the application with docker compose up -d, then browse to the published web port. section 13.4 section 13.6
Listing 13.5 Modeling Nerd Dinner with Docker Compose
services:
db:
image: diamol/ch13-nerd-dinner-db:2e
healthcheck:
test: ["CMD", "powershell", "Test-Path", "/init.done"]
start_period: 30s
networks:
- nd-net
web:
image: diamol/ch13-nerd-dinner-web:2e
environment:
ENV_DB_CONNECTION_STRING: ...
ENV_IPINFODB_KEY: ...
ENV_BINGMAPS_KEY: ...
ports:
- 8083:80
depends_on:
db:
condition: service_healthy
networks:
- nd-net
networks:
nd-net:
Inspect a complete Compose definition containing database and web services, a health check, dependency condition, published port, environment settings, and a shared network. section 13.4
