Bring up and tear down a multi-service stack with docker compose
domain: docs.docker.com · 9 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗
Documented steps
Define services in a compose.yaml/docker-compose.yaml (or override with -f).
Build images and start all services in the foreground: `docker compose up` (aggregates container logs, stops on exit).
Run in the background and leave them running: `docker compose up -d`.
Rebuild images before starting: `docker compose up -d --build`; force-recreate: `docker compose up --force-recreate`.
Wait until services are running/healthy then return: `docker compose up -d --wait` (implies detached).
Start only a subset: `docker compose up -d web db`; scale a service: `docker compose up -d --scale worker=3`.
Tear down: `docker compose down` stops and removes containers + networks created by up (not volumes by default).
Remove named/anonymous volumes too: `docker compose down -v`; remove images with `--rmi local`, remove orphan containers with --remove-orphans.
Official docs: https://docs.docker.com/reference/cli/docker/compose/up/ and https://docs.docker.com/reference/cli/docker/compose/down/
Known gotchas
Attached `docker compose up` stops all containers when you Ctrl-C or the command exits. Use `-d` (detached) for long-lived stacks.
When a service's config or image changes, up recreates that container (preserving mounted volumes); use --no-recreate to prevent, --force-recreate to force.
docker compose down does NOT remove named volumes by default — data persists. Add -v only if you want volumes gone (data is then lost).
The command exits with code 1 on error; Ctrl-C (SIGINT/SIGTERM) stops containers and exits 0.
If the compose file changed to drop a service, old containers linger — use --remove-orphans on up (or down) to clean them.
compose is a separate plugin under docker compose (v2) — not the legacy docker-compose binary flags/behavior in some edge cases.
Give your agent this knowledge — and 17,100+ more routes
One MCP install gives any agent live access to the full route map across 5,900+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?