This Compose deployment keeps its data in a named volume, reads its credentials from a .env file, and runs in a hardened container. Use it once the throwaway quickstart container is no longer enough.
What you get
- The published image from GHCR, with data in the
logsnamed volume mounted at/data. - HTTP published on the host’s
127.0.0.1:3100only. - A read-only root filesystem, a 256 MiB
/tmptmpfs, all Linux capabilities dropped, and a 35-second shutdown grace period. - Seven-day retention, a 20 GB size target per index, at most four indexes, and events archived to Parquet after one day.
Set it up
Create a deployment directory
mkdir logbrook && cd logbrookWrite compose.yaml
It runs the published
ghcr.io/sandrinodm/logbrook:0.5.0image and takes the credentials from.env. To run another release, a digest or your own build, setLOGBROOK_IMAGEin.env.compose.yamlyaml services: logbrook: image: ${LOGBROOK_IMAGE:-ghcr.io/sandrinodm/logbrook:0.5.0} ports: - "127.0.0.1:3100:3100" environment: LOGBROOK_BIND: 0.0.0.0:3100 LOGBROOK_DATA_DIR: /data LOGBROOK_INGEST_TOKEN: ${LOGBROOK_INGEST_TOKEN:?Set a random ingestion token} LOGBROOK_READ_TOKEN: ${LOGBROOK_READ_TOKEN:?Set a different random read token} # LOGBROOK_ADMIN_TOKEN: ${LOGBROOK_ADMIN_TOKEN:?Set a random admin token} LOGBROOK_SOURCE: ${LOGBROOK_SOURCE:-apps} LOGBROOK_RETENTION_DAYS: ${LOGBROOK_RETENTION_DAYS:-7} LOGBROOK_MAX_SIZE_GB: ${LOGBROOK_MAX_SIZE_GB:-20} LOGBROOK_MAX_INDEXES: ${LOGBROOK_MAX_INDEXES:-4} LOGBROOK_INDEXES: ${LOGBROOK_INDEXES:-apps} LOGBROOK_ARCHIVE_AFTER_MS: ${LOGBROOK_ARCHIVE_AFTER_MS:-86400000} LOGBROOK_MAINTENANCE_INTERVAL_SECS: ${LOGBROOK_MAINTENANCE_INTERVAL_SECS:-60} volumes: - logs:/data read_only: true tmpfs: - /tmp:rw,noexec,nosuid,size=256m,mode=1777 cap_drop: - ALL security_opt: - no-new-privileges:true restart: unless-stopped stop_grace_period: 35s volumes: logs:Create .env
This generates both credentials and refuses to overwrite an existing file. Keep
.envout of version control.( set -eu umask 077 set -C cat > .env <<ENV LOGBROOK_INGEST_TOKEN=$(openssl rand -hex 32) LOGBROOK_READ_TOKEN=$(openssl rand -hex 32) ENV )Compose reads
.envfrom the project directory. The ingestion token can only write and the read token can only query, so don’t swap them.Start it
export COMPOSE_PROJECT_NAME=logbrook docker compose config --quiet docker compose up -d --wait --wait-timeout 120config --quietvalidates the file without printing the expanded credentials.--waitreturns once the image’s built-in health check passes.Send and search an event
Load the credentials into your shell, then use the
appsindex that the template precreates.set -a; . ./.env; set +a curl --fail http://127.0.0.1:3100/indexes/apps/logs/ingest \ -H "Authorization: Bearer $LOGBROOK_INGEST_TOKEN" \ -H 'Content-Type: application/json' \ --data "[{ \"time\": $(( $(date +%s) * 1000 )), \"level\": 30, \"service\": \"web\", \"msg\": \"hello from compose\" }]" docker compose exec -T logbrook logbrook query apps --since 1hCheck that data persists
docker compose restart logbrook docker compose exec -T logbrook logbrook query apps --since 1hThe event is still there.
docker compose downkeeps the volume.docker compose down --volumesdeletes it and all your logs.
Change the configuration
After you edit .env, recreate the container with docker compose up -d --wait. A plain restart does not reload the environment. Shell variables override .env, so unset stale ones first.
Common variables, all with defaults in the template:
| Variable | Default | Meaning |
|---|---|---|
LOGBROOK_SOURCE |
apps |
Source assigned to events written with the ingestion token. |
LOGBROOK_INDEXES |
apps |
Comma-separated indexes to precreate. default always exists. |
LOGBROOK_RETENTION_DAYS |
7 |
Retention per index. Must exceed the archive age. |
LOGBROOK_MAX_SIZE_GB |
20 |
Disk-size target per index, in decimal GB. Not a hard quota. |
LOGBROOK_MAX_INDEXES |
4 |
Index slots, including default. |
LOGBROOK_ARCHIVE_AFTER_MS |
86400000 |
Event age before archiving to Parquet. |
LOGBROOK_MAINTENANCE_INTERVAL_SECS |
60 |
Seconds between maintenance passes. |
To add an admin token for index administration, put LOGBROOK_ADMIN_TOKEN in .env, uncomment its line in compose.yaml, and recreate the service. Compose passes only mapped variables, so the token in .env alone does nothing. Keep the line commented out while you have no admin token: an empty token is invalid.
For separate ingestion sources, scoped readers, or per-index policies, mount a TOML file instead. See the configuration file.