✦ For everyone, free.

Practical knowledge for real and everyday life

Home

9.1.1.1 Compose App Services

A focused guide to Compose App Services, connecting core concepts with practical Docker and container operations.

Compose app services are the individual, named entries defined under a Compose file's services key, each corresponding to one container (or set of replicated containers) that together make up the overall multi-container application.

Defining Individual Services

Each service entry specifies how that particular component of the application should be built or sourced, configured, and connected to the rest of the application.

services:
  frontend:
    build: ./frontend
    ports:
      - "3000:3000"
  backend:
    build: ./backend
    environment:
      - PORT=8080
  database:
    image: postgres:16

Each of these three named services represents a distinct component, collectively forming the complete application.

Why Service Names Matter Beyond Just Organization

A service's name is not merely a label for organizational clarity — it's also the name other services automatically use to resolve and reach that service over the network Compose creates.

services:
  backend:
    environment:
      - DATABASE_HOST=database
  database:
    image: postgres:16

Here, backend reaches database directly by this exact name, since Compose automatically makes services resolvable to each other using their defined names.

Starting, Stopping, and Inspecting Individual Services

Compose commands can target a specific service by name, rather than always operating on the entire application at once.

docker compose up -d database
docker compose logs backend
docker compose restart frontend
Scaling a Specific Service

A service can be scaled to run multiple replicas, useful for components that benefit from running several instances simultaneously.

docker compose up -d --scale backend=3
Why Compose App Services Matter

Each service definition is the fundamental building block of a Compose application, and understanding how services are named, configured, and connected is essential to correctly defining and operating any multi-container application through Compose.