LinuxCommandLibrary

docker-compose-up

Run Docker Compose defined application

TLDR

Start all services defined in the docker-compose file

$ docker compose up
copy

Start services in the background (detached mode)
$ docker compose up [[-d|--detach]]
copy

Start services and rebuild images before starting
$ docker compose up --build
copy

Start specific services only
$ docker compose up [service1 service2 ...]
copy

Start services with custom compose file
$ docker compose [[-f|--file]] [path/to/config] up
copy

Start services and remove orphaned containers
$ docker compose up --remove-orphans
copy

Start services with scaled instances
$ docker compose up --scale [service]=[count]
copy

Start services and show logs with timestamps
$ docker compose up --timestamps
copy

SYNOPSIS

docker-compose [global-options] up [up-options] [SERVICE…]

PARAMETERS

-a, --attach
    Attach to service logs (default if no SERVICE specified)

--abort-on-container-exit
    Exit with failure if any container exits

--build
    Build images before starting containers

--no-build
    Skip building images

-d, --detach
    Run in background, print new container names

--force-recreate
    Recreate containers even if unchanged

--no-recreate
    Skip recreation if containers exist

--no-deps
    Don't start linked dependencies

--pull
    Always pull newer images

--remove-orphans
    Remove containers not in compose file

-q, --quiet
    Suppress progress output

--scale SERVICE=NUM
    Scale service to NUM instances

--renew-anon-volumes
    Recreate anonymous volumes

--timeout TIMEOUT
    Shutdown timeout in seconds (default 10)

-t, --timestamps
    Add timestamps to logs

--wait
    Wait for services to be healthy (v3.4+)

DESCRIPTION

The docker-compose up command creates and starts containers for services defined in a docker-compose.yml file. It performs a sequence of actions: pulls or builds images if necessary, creates required networks and volumes, and launches containers in dependency order (services with depends_on start after dependencies). By default, it attaches to service logs for real-time output, making it ideal for development. Specify service names to start only those and their dependencies.

Key behaviors include automatic port publishing, environment variable injection, and health check monitoring. Use options to customize: detach for background running, force recreation for clean starts, or pull latest images. Stopping with Ctrl+C sends SIGTERM and removes containers unless detached. It's the go-to command for local multi-container apps like web servers with databases.

For production, combine with -d for daemon mode and orchestration tools. Supports Compose file versions 1-3.x, with v3+ features like deploy scaling.

CAVEATS

Deprecated in Docker Compose v2+; use docker compose up instead. May fail if ports conflict or images unavailable.

COMMON USAGE

docker-compose up — Start all services interactively.
docker-compose up -d web — Start web service detached.

GLOBAL OPTIONS

-f FILE — Use alternate compose file.
-p NAME — Set project name.

HISTORY

Originated in Fig (2013), acquired by Docker as Compose v1.0 (2016). Python-based CLI; v2 (2021) integrated as Docker plugin with docker compose. up evolved to support healthchecks, scaling.

SEE ALSO

docker-compose(1), docker-compose-down(1), docker-compose-ps(1), docker-compose-logs(1), docker(1)

Copied to clipboard