> For AI agents: the complete documentation index is available at https://docs.hod.sh/llms.txt, the full documentation bundle is available at https://docs.hod.sh/llms-full.txt.

# Services

Services are containers that run beside the job for as long as it runs, such as a database for its tests. They are ready before the first step and removed with the job. The job and its services share one network namespace: steps reach a service at `localhost:<port>` and at `<name>:<port>`.

```yaml
version: 0
on: [push]
jobs:
  test:
    image: golang:1.23
    matrix: {pg: ["16", "17"]}
    services:
      postgres:
        image: postgres:${{ matrix.pg }}
        env: {POSTGRES_PASSWORD: test}
        command: [-c, fsync=off]
      redis: redis:7
    steps:
      - run: go test ./...
        env:
          DATABASE_URL: postgres://postgres:test@localhost:5432/postgres
```

`name: image` is short for `{image: …}`. A service also takes `env`, `command` (replaces the image's `CMD`), `entrypoint` (replaces its `ENTRYPOINT` and drops its `CMD`), `ports` and `ready`.

## Readiness

A service is ready when its `ready:` script succeeds (run in the service with `sh -c`); else when its image's `HEALTHCHECK` says healthy; else once its `ports:`, or the ports its image exposes, are listening. It has 60 seconds by default (`ready: {timeout: 2m}` changes that). A service that isn't ready in time fails the job with reason `setup`.

Names are DNS labels (lowercase letters, digits and `-`), and two services of a job can't listen on the same port. Services only run beside container jobs.
