Docker and service-backed tests
Complete the first-run guide before configuring services.
Configure Postgres
The Docker runner supports service containers, including a built-in Postgres
service. This example assumes a Go repository whose integration tests read
DATABASE_URL. Replace owner/repo and the test package with your own values:
version: 1
project_id: owner/repo
image: ubuntu-24.04-ci-docker
network:
mode: none
warm_mode: allowlist
warm_allowlist: [proxy.golang.org, sum.golang.org, storage.googleapis.com]
cache:
key_files: [go.mod, go.sum]
services:
postgres:
type: postgres
version: "16"
env:
POSTGRES_DB: readyci
POSTGRES_PASSWORD: readyci
health:
command: pg_isready -U postgres
timeout: 30s
interval: 2s
checks:
dependencies:
command: go mod download
integration:
docker: true
services: [postgres]
command: go test ./integration/...
The check must be named dependencies for Ready CI to run it automatically
before the selected test. Keep preparation enabled: an empty or evicted cache
needs these downloads before the offline test can run. Preparation uses
network.warm_mode and network.warm_allowlist; the test keeps network.mode: none.
The runner sets GOMODCACHE=/cache/go/pkg/mod and GOCACHE=/cache/go/build.
These built-in caches already live on the persistent cache disk; do not add
/cache paths to cache.paths. Use cache.paths only for additional directories
outside /cache.
The password above is a disposable test fixture, not a production credential.
The runner starts the database, waits for the health probe, and supplies
DATABASE_URL, PGHOST, PGPORT, PGUSER, PGPASSWORD, and PGDATABASE to
the check. Use these variables instead of assuming the database is on localhost.
The service is removed after the check.
Preview and run
readyci config validate
readyci doctor --check integration --json
readyci check --dry-run --why --json integration
readyci check integration
Review the dependency preparation shown by the dry run. Registry access belongs to preparation; the test remains offline. The worker must carry the selected service image. Generic containers also require a preloaded image and an explicit health probe; an unavailable image fails instead of being downloaded implicitly. Use service configuration for the fields.
Use Testcontainers
For Testcontainers, enable docker: true, choose the Docker runner image, and
make your tests request images the worker already has. Enabling Docker alone
does not install images or grant network access. Docker-capable workers preload
these images:
postgres:15,postgres:16andpostgres:17valkey/valkey:8.1
Other tags, including variants such as postgres:16-alpine and
valkey/valkey:8.1-bookworm, are absent, and the offline test cannot download
them. If your test helper reads its image tag from an environment variable, set
that variable to a preloaded tag in the check command.
Testcontainers' published ports work offline. With network.mode: none, the
runner has no external network interface, so containers and their published
ports stay inside it: your test reaches them on localhost, and nothing
reaches the internet. Testcontainers for Go, Java and Node also start the Ryuk
cleanup container, whose image is not preloaded. Set
TESTCONTAINERS_RYUK_DISABLED=true in the check command; the runner removes
every container when the check ends. Diagnose image, daemon, and health-probe
failures with
Docker troubleshooting.