docker compose up Command Reference
Create and start the services defined in a compose file.
docker compose up builds (if needed), creates, and starts the services in a compose file, along with their network and volumes. In CI you run it detached with -d and ideally --wait so the job only proceeds once services are healthy.
Common flags
-d, --detach- run services in the background--build- build images before starting, even if they exist--wait- block until services are running and healthy--wait-timeout- seconds to wait before failing--abort-on-container-exit- stop all services if any container exits--force-recreate- recreate containers even if config is unchanged
Example
shell
docker compose up -d --build --wait
docker compose run --rm app npm run test:e2eIn CI
Use -d --build --wait so the step returns only after every service with a healthcheck reports healthy, eliminating flaky "connection refused" races before tests. --wait requires healthchecks defined in the compose file; without them it returns as soon as containers are running, not ready.
Key takeaways
- -d --build --wait is the canonical CI invocation.
- --wait depends on compose-file healthchecks to know a service is ready.
- It eliminates startup races that cause flaky "connection refused" failures.
Related guides
docker compose down Command ReferenceReference for docker compose down in CI: stop and remove containers, networks, and with -v the volumes, to te…
docker compose build Command ReferenceReference for docker compose build in CI: build service images defined in a compose file with --no-cache, --p…
docker compose run Command ReferenceReference for docker compose run in CI: run a one-off command in a service container with --rm, -e, and --no-…