Skip to main content

Docker Compose (local)

A single-command local stack for memledger development. Brings up Postgres + pgvector on localhost:5433 so it doesn't conflict with a system Postgres on 5432.

docker-compose.yaml

Drop this into a working directory:

services:
postgres:
image: pgvector/pgvector:pg17
ports:
- "5433:5432" # HOST:CONTAINER (5433 host avoids local-pg conflict)
environment:
POSTGRES_USER: memledger
POSTGRES_PASSWORD: memledger
POSTGRES_DB: memledger
volumes:
- pgdata:/var/lib/postgresql/data

volumes:
pgdata:

Run

docker compose up -d

What gets started

  • A single postgres service exposing port 5433 on the host.
  • A named volume pgdata that persists across docker compose down (drop with -v).
  • The pgvector/pgvector:pg17 image, which has the vector extension preloaded.

Verify:

docker compose ps
docker compose logs postgres | grep "ready to accept connections"

Connect from Python

import asyncio
from memledger import Memledger
from memledger.models import EmbeddingConfig

async def main():
ml = await Memledger.create(
backend_name="pgvector",
connection_string="postgresql://memledger:memledger@localhost:5433/memledger",
embedding_config=EmbeddingConfig(provider="local"),
)

await ml.add(
content="HikariCP maxPoolSize=50 fixes payment-service OOM",
namespace="/ops/incidents/payment-svc",
confidence=0.9,
created_by="ops-agent",
)

results = await ml.search(query="connection pool fix",
namespace="/ops/incidents/payment-svc")
for r in results.records:
print(r.confidence, r.created_by, "::", r.content)

await ml.close()

asyncio.run(main())

EmbeddingConfig(provider="local") pulls the BAAI/bge-small ONNX model on first use (~130 MB). No cloud credentials are needed.

Teardown

docker compose down # stops containers, keeps the volume
docker compose down -v # also drops pgdata (full reset)

Next steps