Environment:AFK surf Open agent Postgres Pgvector
| Knowledge Sources | |
|---|---|
| Domains | Database, Deployment, Self_Hosting |
| Last Updated | 2026-10-25 00:00 GMT |
Overview
PostgreSQL 16 with the pgvector extension, run as a Docker container (`pgvector/pgvector:pg16`), providing the primary relational and vector store for the Open-Agent self-hosting stack.
Description
This environment provides the database service for the Self_Hosting_Deployment workflow. The compose file pulls the `pgvector/pgvector:pg16` image, which bundles PostgreSQL 16 with the pgvector extension for vector similarity search. It creates a `open_agent` database on first boot, persists data to a bind-mounted `./database` volume, and exposes a `pg_isready` healthcheck that the `app-init` and `app` services wait on.
Usage
Use this environment as a required dependency of Docker_Compose_Stack. It is the mandatory data store for the Open-Agent application; the `app-init` service runs migrations/seed against it before the `app` server starts.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| Runtime | Docker Engine (see Docker_Engine) | Runs as a compose service; no host Postgres install needed |
| Disk | 1GB+ free | For the `./database` bind-mount volume (grows with usage) |
| Memory | 512MB+ dedicated | Postgres default `shared_buffers` is fine for the default config |
Dependencies
System Packages
- Docker Engine (see Environment:AFK_surf_Open_agent_Docker_Engine)
Image References
- `pgvector/pgvector:pg16` — PostgreSQL 16 with the pgvector extension preinstalled
Connection
- `DATABASE_URL=postgres://postgres:postgres@postgres:5432/open_agent` (internal compose network; the host/port/user/password are set in the compose `environment` block)
Credentials
The following are set in the `docker-compose.yml` `postgres` service `environment` block (defaults shown; override for production):
- `POSTGRES_DB` — database name (default `open_agent`)
- `POSTGRES_USER` — database user (default `postgres`)
- `POSTGRES_PASSWORD` — database password (default `postgres`; change for production)
Never commit real production credentials to the compose file — use Docker secrets or an `.env` file.
Quick Install
# Start only the data services (from the deploy directory):
docker compose up -d postgres
# Verify health:
docker compose ps postgres # should show "healthy"
docker compose exec postgres psql -U postgres -d open_agent -c "SELECT 1;"
Code Evidence
Postgres service definition from `.docker/docker-compose.yml:2-15`:
postgres:
image: pgvector/pgvector:pg16
environment:
POSTGRES_DB: open_agent
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
volumes:
- ./database:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U postgres']
interval: 5s
timeout: 5s
retries: 5
restart: unless-stopped
DATABASE_URL wiring for app services from `.docker/docker-compose.yml:31-32,48`:
app-init:
environment:
- DATABASE_URL=postgres://postgres:postgres@postgres:5432/open_agent
app:
environment:
- DATABASE_URL=postgres://postgres:postgres@postgres:5432/open_agent
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `psql: FATAL: password authentication failed` | `POSTGRES_PASSWORD` changed after first init | The bind-mounted `./database` retains the old password; stop the container, remove `./database`, and restart |
| `pg_isready` never becomes healthy | Volume permission mismatch on `./database` | Ensure the directory is writable by the container user (uid 999 on the pgvector image) |
| app fails with `relation does not exist` | `app-init` migrations did not run | Start `app-init` first (`docker compose up app-init`) before starting `app` |
| `extension "vector" does not exist` | Running plain `postgres:16` instead of `pgvector/pgvector:pg16` | Use the `pgvector/pgvector:pg16` image exactly as in the compose file |
Compatibility Notes
- External Postgres: You may replace the compose `postgres` service with an externally managed Postgres — ensure the pgvector extension is installed (`CREATE EXTENSION vector;`) and set `DATABASE_URL` accordingly in the `app`/`app-init` environment.
- Postgres 15/17: The pgvector image also publishes `pg15`/`pg17` tags; switching is untested against the Open-Agent schema.
- Data persistence: The `./database` bind mount is required to survive container recreation; without it, data is lost on `docker compose down`.