Skip to content

Guides

How to use service containers properly

Tests fail intermittently at startup.

4 min read

Tests fail intermittently at startup.

Why it happens

The job races the service container's readiness because no healthcheck is defined.

How to fix it

  1. Define a healthcheck with an appropriate interval and retry count
  2. Use docker compose up --wait when running compose rather than services
  3. Never use a fixed sleep as a readiness substitute

Your next build could be twice as fast, at half the price

Start free. Migrating away is the same one line, and we publish that diff too.