liveBook · Manning

Compose specification

As explained in Learn Docker in a Month of Lunches, Second Edition

The Compose specification is the declarative standard for defining multi-container applications and their services, configuration, and relationships.

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

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Demonstrates service definitions, networking, health checks, and conditional startup, without detailing the complete specification.
Examples
Uses a Nerd Dinner web service and SQL Server database, plus a legacy ASP.NET Windows application migration lab.
What you can do after
Operate/configure Docker Compose applications with published ports, shared networks, environment settings, and health-gated startup.
How it connects
Connects Docker containers with networks, health checks, service dependencies, and SQL Server databases.

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.