Run it locally
Start brain-db from the published image, wire brain-edge to it correctly, mint a key, and confirm the whole path is serving.
Linux kernel 5.15+, Docker, and roughly 12 GiB of memory available to the Docker VM. See what it needs.
Just the database
docker run --rm --name brain \
-p 8080:8080 -p 9091:9091 \
--security-opt seccomp=unconfined --ulimit memlock=-1 \
-e BRAIN__LLM__BROKER__URL=http://brain-edge:8080 \
-e BRAIN__LLM__BROKER__SERVICE_KEY=dev-service-key \
-e BRAIN__ADMIN__TOKEN=dev-admin-token \
-v brain-data:/var/lib/brain/data \
-v brain-models:/var/lib/brain/models \
ghcr.io/arc-labs-ai/brain-db:0.4.0Ports, as the image's baked config/docker.toml sets them:
| Port | What | Exposed |
|---|---|---|
8080 | Wire protocol — BRN0 frames + CBOR over TCP | yes |
9091 | /healthz, /readyz, /metrics | yes — public, no auth |
9092 | Admin plane, /v1/* | loopback only, inside the container |
Confirm it is alive:
curl -s http://127.0.0.1:9091/healthz # liveness — the process is up
curl -s http://127.0.0.1:9091/readyz # 200 once every shard serves, 503 otherwiseTwo wire-port defaults exist, and both are correct
The published image bakes config/docker.toml, which binds the wire protocol
to 8080. The repository's config/dev.toml — what you get building from
source — binds it to 9090, and binds all three listeners to loopback.
Check [server] listen_addr for the config you are actually running, or
override it with BRAIN__SERVER__LISTEN_ADDR.
No provider key goes in here
There is deliberately no LLM key in the docker run above. Brain resolves one per
namespace from the broker, and BRAIN__LLM__API_KEY neither satisfies the
boot gate nor serves a namespace — but a rejected one makes the server
refuse to start, so adding it to "make extraction work" is the one change
that can turn a booting container into a failing one. See
[llm] api_key.
It speaks the binary wire protocol. curl against it will hang or garble —
it is not broken, it is the wrong protocol. For JSON you need brain-edge,
below, which is a different process that also happens to default to 8080.
Note both volumes. Without -v on the data directory, --rm throws your data
away when the container stops; without the model volume, every restart
re-downloads roughly 1.8 GiB of models.
Adding the HTTP edge
Two processes that have to find each other, so compose is the honest way:
# compose.yml
services:
brain:
image: ghcr.io/arc-labs-ai/brain-db:0.4.0
security_opt: ["seccomp=unconfined"]
ulimits:
memlock: -1
environment:
BRAIN__LLM__BROKER__URL: http://edge:8080
BRAIN__LLM__BROKER__SERVICE_KEY: dev-service-key
BRAIN__ADMIN__TOKEN: dev-admin-token
volumes:
- brain-data:/var/lib/brain/data
- brain-models:/var/lib/brain/models
ports:
- "9091:9091"
healthcheck:
test: ["CMD", "curl", "-fsS", "http://127.0.0.1:9091/healthz"]
interval: 10s
timeout: 3s
retries: 3
start_period: 30s
edge:
image: ghcr.io/arc-labs-ai/brain-edge:0.4.0
depends_on:
brain:
condition: service_healthy
environment:
BRAIN_ADDR: brain:8080 # ← required; see below
BRAIN_EDGE_LISTEN: 0.0.0.0:8080
ports:
- "8080:8080"
volumes:
brain-data:
brain-models:docker compose up
curl -s http://127.0.0.1:8080/health/readySet BRAIN_ADDR, or the edge never reaches the database
BRAIN_ADDR defaults to 127.0.0.1:7878 — loopback inside the edge's own
container, on a port nothing is listening on. An edge started without it comes
up, serves /health/live, answers /health/ready with 503, and fails every
data request. Point it at the database's wire port (8080 in the image,
9090 from source), not at another HTTP port.
The variable really is BRAIN_ADDR, with no BRAIN_EDGE_ prefix.
BRAIN_EDGE_BRAIN_ADDR looks right next to the rest of the edge's names and
is silently ignored, which leaves the default in place — the exact failure
this warning is about.
The circular reference is not a deadlock
brain-db points BRAIN__LLM__BROKER__URL at the edge, and the edge points
BRAIN_ADDR at brain-db. That is fine: the broker is consulted lazily,
only when a write needs to derive, so neither waits on the other to boot.
The healthcheck gate above just avoids a noisy first few seconds.
Which health endpoint belongs to which process
| Process | Endpoint | Meaning |
|---|---|---|
brain-db, :9091 | /healthz | The process is up |
brain-db, :9091 | /readyz | Every shard is serving |
brain-edge, :8080 | /health/live | Static — the edge process is up |
brain-edge, :8080 | /health/ready | The edge probes Brain — use this for load-balancer membership |
/health/ready is the one an orchestrator should gate on: it is the only
signal that says the edge can actually reach the database it proxies to. Note
that these two live on the edge binary; the library router it is built from
serves /v1/* only, so a host application embedding the crate owns its own
health routes.
Getting a key
Every connection must present a resolvable API key — there is no anonymous
mode. Keys are minted on the admin plane, which binds loopback inside the
container, so reach it with docker exec:
docker exec brain curl -s \
-H "Authorization: Bearer $BRAIN_ADMIN_TOKEN" \
http://127.0.0.1:9092/v1/shardsThat both proves your admin token works and shows per-shard status. The same listener carries key mint and revoke — see API keys.
Then talk to it
Over HTTP through the edge, or straight to the wire port with an SDK:
export BRAIN_BASE_URL=http://127.0.0.1:8080
export BRAIN_API_KEY=brain_…
curl -s "$BRAIN_BASE_URL/v1/whoami" -H "Authorization: Bearer $BRAIN_API_KEY"import { BrainClient } from "@brain-db/sdk";
const client = await BrainClient.connect("127.0.0.1", 8080, {
auth: { kind: "token", token: new TextEncoder().encode(process.env.BRAIN_API_KEY!) },
});from brain_db_sdk import Auth, BrainClient
with BrainClient.connect("127.0.0.1", 8080, Auth.token(api_key.encode())) as client:
print(client.namespace)use brain_db_sdk::{Auth, BrainClient};
let client = BrainClient::connect(addr, Auth::Token(api_key.into_bytes())).await?;Note the asymmetry: Python's Auth exposes static constructors
(Auth.token(...)), while Rust's is a plain enum, so the variant is
Auth::Token(...).
Developing on Brain itself
Working on the engine rather than with it is a different setup — clone the
repo and use the dev container, which builds from source and gives you
just verify. See the repository README.
Was this page helpful?
Run
Operating Brain yourself — the two processes, the platform it requires, the memory it needs, and the three things it refuses to start without.
Configuration
Both processes' settings — brain-db's TOML with environment overrides, brain-edge's pure-environment config, and the choices pinned at creation.