Run integration tests against a service container.

Section: Run with databases or environment-specific settings

Start PostgreSQL service for tests

yaml
yaml
services:
  postgres:
    image: postgres:16
    env:
      POSTGRES_PASSWORD: postgres
    ports:
      - 5432:5432
    options: >-
      --health-cmd "pg_isready -U postgres"
      --health-interval 10s
      --health-timeout 5s
      --health-retries 5
Explanation

Service containers are useful for test environments that need databases, Redis, or other dependencies.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Run with databases or environment-specific settings
Use named environments
Attach production jobs to an environment with protection rules.
OpenIn sheetyamlsame section
Run deploy only on deployment-capable agents
Target jobs to specific Jenkins workers or labels.
OpenIn sheetgroovysame section
Build and push Docker image with GitHub Actions
Authenticate, build, and push to a registry.
Build image in GitLab CI
Use Docker-in-Docker or a compatible runner setup.
Deploy a new image to Kubernetes
Update a deployment image and monitor rollout status.