Run with Docker Compose
This page explains how to run Magnet AI locally using the repository’s root docker-compose.yml (includes PostgreSQL + pgvector).
For production deployment guidance, use the DevOps Guide:
/docs/en/devops/deployment/docker-compose//docs/en/devops/deployment/kubernetes/
Prerequisites
- Docker Desktop / Docker Engine
- Docker Compose v2 (
docker compose) - 4GB+ RAM (more recommended for first build)
Quick start
From the repository root:
bash
# 1) Create a root .env file (see example below)
# 2) Build + start services
docker compose up -d --buildWhen it’s up, you can access:
- User Panel:
http://localhost:5000/panel/ - Admin Console:
http://localhost:5000/admin/ - API health:
http://localhost:5000/health - Help/Docs (offline):
http://localhost:5000/help/
Environment configuration
docker-compose.yml loads variables from a root .env file.
Create .env in the repository root:
bash
# Required for AI features
OPENAI_API_KEY=sk-...
# App port (host -> container). Default: 5000
PORT=5000
# Postgres (host port is exposed as DB_PORT; container uses 5432 internally)
DB_NAME=magnet_dev
DB_USER=postgres
DB_PASSWORD=password
DB_PORT=5433
# Local convenience (recommended)
AUTH_ENABLED=falseNotes:
- The database is exposed on your machine as
localhost:${DB_PORT}(default5433). - The app container connects to Postgres via the Docker network (
DB_HOST=postgres,DB_PORT=5432inside the network).
What Docker Compose runs
The root docker-compose.yml starts:
postgres:pgvector/pgvector:pg16with an init script that enablespgvectorapp: the Magnet AI API (Litestar) plus bundled static web apps (served from the same container)
On container start, Magnet automatically:
- waits for Postgres
- applies DB migrations (unless disabled)
Common commands
Stop / start
bash
docker compose up -d
docker compose downView logs
bash
docker compose logs -f app
docker compose logs -f postgresRebuild the app image
bash
docker compose build app
docker compose up -d --force-recreate appFaster builds (skip docs build)
The Docker image can optionally skip building the documentation for faster iteration.
In your .env:
bash
BUILD_DOCS=falseThen rebuild:
bash
docker compose build app
docker compose up -d --force-recreate appDatabase access (from your host)
To connect from your machine (e.g., DBeaver), use:
- Host:
localhost - Port:
${DB_PORT}(default5433) - Database:
${DB_NAME}(defaultmagnet_dev) - User:
${DB_USER}(defaultpostgres) - Password:
${DB_PASSWORD}(defaultpassword)
Resetting the database (danger)
The container supports a destructive reset mode that drops all tables and reapplies migrations.
- Set this in
.envtemporarily:
bash
RESET_DB=true- Recreate the
appcontainer so it picks up the updated env var:
bash
docker compose up -d --force-recreate app- Set
RESET_DB=falseagain and recreate theappcontainer once more.
Next steps
- Local Development - Hot reload / contributor workflow
- Testing - Running test suites
- DevOps Guide - Production deployment & operations