Docker Engine 29 reference · Docker Compose

docker compose up Command (Docker CLI)

Create and start every service of a Compose project; -d runs in the background and --wait returns once services are healthy.

Docker Engine 29

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

docker compose up [OPTIONS] [SERVICE...]

Parameters

ParameterDescription
-d Detached mode.
--wait Wait until services are running and healthy.
--build Build images before starting.
-p NAME Project name (defaults to the directory name).

Examples

Start and wait for health
cat > compose.yaml <<'EOF'
services:
  cache:
    image: redis:8-alpine
    healthcheck: {test: ["CMD", "redis-cli", "ping"], interval: 1s, retries: 20}
EOF
docker compose -p rc-ref-up up -d --wait > /dev/null 2>&1
docker compose -p rc-ref-up ps --format '{{.Service}}: {{.State}} ({{.Health}})'
docker compose -p rc-ref-up down > /dev/null 2>&1

Output

cache: running (healthy)

Run this on your computer — see “Get Started” for setup.

Foreground output
cat > compose.yaml <<'EOF'
services:
  job:
    image: alpine:3.24
    command: echo one-off task done
EOF
docker compose -p rc-ref-up2 up 2>/dev/null | grep -o 'one-off task done'
docker compose -p rc-ref-up2 down > /dev/null 2>&1

Output

one-off task done

Run this on your computer — see “Get Started” for setup.

Was this page helpful?