# Docker

> Run the engine with Docker Compose, with Postgres, storage and the Docker runner.

Applies to: the Sypnia engine (open source, self-hosted).  
Source: https://learn.docs.sypnia.com/self-hosting/docker/

For agents: compose.yaml: learn (ghcr.io/sespinosav/sypnia-learn:1, 8097, SYPNIA_LEARN_*), db (postgres:16), storage (minio), runner (ghcr.io/sespinosav/sypnia-learn-runner:1: runs each check in a throwaway container with no network except package registries, no host mounts, 2 CPU / 2 GB / 10 min; needs the Docker socket only in the runner container; better: point SYPNIA_LEARN_RUNNER at an Agent sandbox). Health GET /v1/health; metrics GET /metrics with the root token. Migrations: SYPNIA_LEARN_AUTO_MIGRATE=true or docker compose run learn sypnia-learn migrate. Size: 256 MB for the engine; the runner needs about 2 GB per check running at once.

`compose.yaml`

```yaml
services:
  learn:
    image: ghcr.io/sespinosav/sypnia-learn:1
    ports: ["8097:8097"]
    environment:
      SYPNIA_LEARN_DATABASE_URL: postgres://sypnia:${DB_PASSWORD}@db:5432/sypnia_learn
      SYPNIA_LEARN_ROOT_TOKEN: ${SYPNIA_LEARN_ROOT_TOKEN}
      SYPNIA_LEARN_PUBLIC_URL: https://learn.myschool.org
      SYPNIA_LEARN_OIDC_ISSUER: https://accounts.myschool.org
      SYPNIA_LEARN_OIDC_CLIENT_ID: sypnia-learn
      SYPNIA_LEARN_STORAGE_URL: s3://sypnia-learn?endpoint=http://storage:9000
      SYPNIA_LEARN_RUNNER: docker=http://runner:8098
      SYPNIA_LEARN_RUNNER_SECRET: ${RUNNER_SECRET}
      SYPNIA_LEARN_AI_URL: http://ai:8095/v1
      SYPNIA_LEARN_AUTO_MIGRATE: "true"
    depends_on: [db, storage, runner]
  runner:
    image: ghcr.io/sespinosav/sypnia-learn-runner:1
    environment:
      SYPNIA_LEARN_RUNNER_SECRET: ${RUNNER_SECRET}
    volumes: ["/var/run/docker.sock:/var/run/docker.sock"]
  db:
    image: postgres:16
    environment: { POSTGRES_USER: sypnia, POSTGRES_PASSWORD: "${DB_PASSWORD}", POSTGRES_DB: sypnia_learn }
    volumes: [db:/var/lib/postgresql/data]
  storage:
    image: minio/minio
    command: server /data
    volumes: [storage:/data]
volumes: { db: {}, storage: {} }
```

- **The Docker runner** runs each check in a throwaway container: no network except package registries, nothing from the host mounted, 2 CPUs, 2 GB and 10 minutes at most. It is the only container that sees the Docker socket. For stronger isolation, point `SYPNIA_LEARN_RUNNER` at a [Sypnia Agent](https://agent.docs.sypnia.com/) sandbox instead.
- **Explanations** need a model endpoint; leave `SYPNIA_LEARN_AI_URL` out and «Explain this» and hints are off.
- **Health** is `GET /v1/health`; metrics for Prometheus at `GET /metrics`, with the root token.
- **Size.** The engine needs about 256 MB of memory. The runner needs about 2 GB for each check running at the same time.
