Knowledge

docker compose up: options and common flags

#Development

docker compose up reads your compose file and starts every service in it. The flags you reach for most are -d to run in the background and --build to rebuild images first.

Published by Mark van Eijk on June 23, 2026 · 1 minute read

  1. Start your services
  2. Run in the background
  3. Rebuild images first
  4. Start only some services
  5. Stopping again
  6. A note on the command name

Start your services

Run from the directory containing your compose.yaml (or docker-compose.yml):

docker compose up

This creates and starts every service defined in the file, and streams their logs to your terminal. Press Ctrl+C to stop them.

Run in the background

Most of the time you want the stack running detached, so your terminal is free:

docker compose up -d

Check what is running and follow the logs separately:

docker compose ps
docker compose logs -f

Rebuild images first

If you changed a Dockerfile or the build context, force a rebuild before starting:

docker compose up -d --build

To throw away cached containers and recreate them from scratch:

docker compose up -d --force-recreate

Start only some services

Pass service names to start a subset. Add --no-deps if you do not want its linked services started too:

docker compose up -d web
docker compose up -d --no-deps web

Stopping again

Ctrl+C stops a foreground up. For a detached stack, bring it down explicitly. down also removes the containers and network; stop just halts them:

docker compose down       # stop and remove containers + network
docker compose stop       # stop but keep the containers

A note on the command name

Modern Docker uses docker compose (a built-in subcommand, Compose v2). The older standalone tool was docker-compose with a hyphen. If docker compose is not found, you are likely on an old install, upgrade Docker, or fall back to docker-compose.

Once it is up, docker exec lets you run commands inside a running service, and docker prune cleans up afterwards.

Subscribe to our newsletter

Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!

Related articles

Install PHP memcached extension on macOS

docker compose up reads your compose file and starts every service in it. The flags you reach for most are -d to run in the background and --build to rebuild images first.

Read more →

How to delete a local (and remote) Git branch

docker compose up reads your compose file and starts every service in it. The flags you reach for most are -d to run in the background and --build to rebuild images first.

Read more →