✦ For everyone, free.

Practical knowledge for real and everyday life

Home

9.4.1.1 Up Service Creation

A focused guide to Up Service Creation, connecting core concepts with practical Docker and container operations.

Up service creation is the part of docker compose up's overall behavior specifically responsible for creating and starting each defined service's container, applying that service's full configuration — image, environment, volumes, networking — exactly as declared in the Compose file.

How Compose Creates Each Service's Container

For every service the up command needs to bring up, Compose constructs a container configuration matching that service's declared settings, then creates and starts the corresponding container.

services:
  api:
    build: .
    ports:
      - "8080:8080"
    environment:
      - LOG_LEVEL=debug
docker compose up -d api

Compose creates this container with exactly the port mapping, environment variables, and other configuration declared for api, equivalent to what a carefully constructed docker run command with matching flags would produce.

Why Containers Aren't Recreated Unnecessarily

Running up again when nothing about a service's configuration has changed typically doesn't recreate that service's container — Compose recognizes the existing container already matches the current configuration and leaves it running as-is.

docker compose up -d
docker compose up -d

The second invocation here generally has no effect on already-running, unchanged services, avoiding unnecessary restarts.

Forcing Recreation When Genuinely Needed

The --force-recreate flag bypasses this optimization, recreating every service's container regardless of whether Compose detects a configuration change.

docker compose up -d --force-recreate
Why Up Service Creation Matters

This core mechanism — translating each service's declared configuration into an actual running container — is what makes Compose's declarative file genuinely functional, reliably producing containers that match the Compose file's configuration without requiring manual, individually issued docker run commands.