Learning path

Full curriculum

Full curriculum

Arrows go from each prerequisite to the units that depend on it. Hover or focus a unit to highlight its path.

Unit content

Compose for multi-container applications

Compose describes a group of related containers as one application configuration. A YAML file declares the services and resources needed to run them together.

Services

A service describes how one kind of container should run:

services:
  app:
    build: .
    ports:
      - "8080:8080"
  db:
    image: postgres

The configuration can build a local image or reference an existing one and can define environment variables, commands, mounts and exposed ports.

Service networking

Services in the same Compose application can normally reach each other through service names on a managed network. An application can therefore connect to db rather than depending on a host-specific IP address.

Volumes

Named volumes keep selected data outside a container's disposable writable layer. Bind mounts instead connect a host path directly into a container, which is useful for source code during development.

Dependencies and readiness

A service may need another service to be started first, but process startup does not necessarily mean the dependency is ready to accept work. Health checks or application-level retries can express that distinction.

Environment-specific composition

Profiles, overrides and environment variables can vary optional services or configuration without rebuilding the whole application definition.

Compose makes a multi-process development or deployment environment reproducible as a set of cooperating container services rather than a collection of unrelated manual commands.