a container that sets up for other containers. for example, you could populate a database with seed data and share it with your real db container through a volume
support was added in this PR but i haven't seen easily google-able docs yet (maybe im just bad at searching)
here's some imaginary node service backed by postgres which needs to run knex migrations before starting for some reason. It waits for the postrges service to be ready, waits for migrations to complete, and only then starts the node service
version: "3.9"
services:
server:
build: .
environment:
POSTGRES_HOST: db
depends_on:
db:
condition: service_healthy
db_migrations:
condition: service_completed_successfully
db_migrations:
build: .
environment:
POSTGRES_HOST: db
depends_on:
db:
condition: service_healthy
command: "yarn knex migrate:latest --knexfile src/knexfile.ts"
db:
image: postgres:alpine
environment:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5