docker compose up: options and common flags
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.
- Start your services
- Run in the background
- Rebuild images first
- Start only some services
- Stopping again
- 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. If docker compose can't reach the engine at all, see cannot connect to the Docker daemon.