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:e2e
In 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.
Frequently asked questions
docker compose up Command Reference?
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.
In 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.