Skip to content

Docker Deployment

This page covers deploying AutoMem using Docker Compose for local development and self-hosted production environments. Docker Compose provides a complete, isolated stack with FalkorDB, Qdrant, and the Flask API running in containers with persistent volumes.

For cloud deployment on Railway, see Railway Deployment. For environment variable reference across all deployment types, see the Configuration Reference.

Docker Compose orchestrates four services defined in docker-compose.yml: the Flask API, FalkorDB graph database, Qdrant vector store, and an optional FalkorDB browser for visualization.

graph TB
    subgraph host["Host Machine"]
        Make["make dev<br/>docker-compose up"]

        subgraph docker["Docker Network<br/>automem_default"]
            API["memory-service<br/>app.py<br/>localhost:8001"]
            Falkor["falkordb<br/>localhost:6379"]
            QdrantLocal["qdrant<br/>localhost:6333"]
        end

        subgraph volumes["Docker Volumes"]
            FalkorVol["falkordb_data<br/>/var/lib/falkordb/data"]
            QdrantVol["qdrant_data<br/>/qdrant/storage"]
        end
    end

    subgraph tools["Development Tools"]
        Curl["curl<br/>localhost:8001"]
        Python["Python Scripts<br/>scripts/"]
        Tests["pytest<br/>tests/"]
    end

    Make --> API
    Make --> Falkor
    Make --> QdrantLocal

    API --> Falkor
    API --> QdrantLocal

    Falkor --> FalkorVol
    QdrantLocal --> QdrantVol

    Curl --> API
    Python --> API
    Tests --> API
ServiceImage/BuildPortsPurposeHealth Check
flask-apiBuilt from Dockerfile8001AutoMem Flask API with background workersNone (depends on FalkorDB health)
falkordbfalkordb/falkordb:latest6379 (Redis), 3000 (UI)Graph database (canonical memory storage)redis-cli ping every 10s
qdrantqdrant/qdrant:v1.11.36333Vector search database (optional)None (service_started)
falkordb-browserfalkordb/falkordb-browser:latest3001Web-based graph visualizationNone (profile-gated)

Docker Compose defines three named volumes for persistent data and one bind mount for source code. This ensures data survives container restarts and enables hot-reload during development.

VolumeContainer PathPurposePersistence LevelBackup Strategy
falkordb_data/dataRDB snapshots + AOF (append-only file)High (every 60s or 1 key change)Export via redis-cli SAVE to /backups
qdrant_data/qdrant/storageVector collections + write-ahead logHigh (write-ahead log)Export via Qdrant API to /backups
fastembed_models/root/.config/automem/modelsDownloaded ONNX embedding modelsMedium (cache, re-downloadable)Not backed up (excluded in .gitignore)
. (bind mount)/appSource code for hot-reloadN/A (host filesystem)Git repository
./backups/falkordb/backupsManual RDB exportsN/A (host filesystem)Excluded in .gitignore
./backups/qdrant/backupsManual snapshot exportsN/A (host filesystem)Excluded in .gitignore

FalkorDB runs with aggressive persistence enabled via REDIS_ARGS:

  • --save 60 1: Create RDB snapshot every 60 seconds if at least 1 key changed
  • --appendonly yes: Enable AOF (append-only file) for durability
  • --appendfsync everysec: Sync AOF to disk every second
  • --dir /data: Store persistence files in /data (mounted volume)

This configuration prioritizes data safety over performance, suitable for development where memory operations should not be lost on container restart.

The Flask API service accepts environment variables for configuration. Most have sensible defaults for local development.

VariableDocker Compose DefaultPurposeNotes
PORT8001Flask API portMust match container port mapping
AUTOMEM_API_TOKEN${AUTOMEM_API_TOKEN:-test-token}Client authenticationSet via shell or .env
ADMIN_API_TOKEN${ADMIN_API_TOKEN:-test-admin-token}Admin endpoint authenticationSet via shell or .env
FALKORDB_HOSTfalkordbFalkorDB service nameDocker internal DNS resolution
FALKORDB_PORT6379FalkorDB portStandard Redis port
VariableDocker Compose DefaultPurposeNotes
FLASK_ENVdevelopmentFlask environment modeEnables debug mode, hot-reload
FLASK_DEBUG"1"Flask debug flagEnables detailed error pages
FALKORDB_PASSWORD${FALKORDB_PASSWORD:-}FalkorDB authenticationEmpty by default (no auth)
QDRANT_URLhttp://qdrant:6333Qdrant endpointDocker internal URL
QDRANT_API_KEY${QDRANT_API_KEY:-}Qdrant authenticationNot required for local Qdrant
OPENAI_API_KEY${OPENAI_API_KEY:-}OpenAI API accessFalls back to placeholder embeddings
EMBEDDING_PROVIDER${EMBEDDING_PROVIDER:-auto}Provider selection`auto
AUTOMEM_MODELS_DIR/root/.config/automem/modelsFastEmbed model cacheMust match volume mount path

Environment variables can be set three ways (in order of precedence):

  1. Process environment: export OPENAI_API_KEY=sk-... before running docker compose up
  2. .env file: Create .env in project root with OPENAI_API_KEY=sk-...
  3. Docker Compose defaults: Fallback values in docker-compose.yml

Docker Compose manages startup order and readiness using depends_on conditions and health checks. This prevents the Flask API from attempting to connect to FalkorDB before it’s ready.

Health Check Details

FalkorDB is the only service with a health check defined:

  • Test command: redis-cli ping (expects PONG response)
  • Interval: Check every 10 seconds
  • Timeout: Fail if command doesn’t respond within 5 seconds
  • Retries: Attempt 5 times before marking unhealthy
  • Initial delay: No explicit start_period, begins checking immediately

The Flask API waits for condition: service_healthy, ensuring FalkorDB is accepting connections before the API attempts to connect.

Qdrant uses condition: service_started, meaning the Flask API starts as soon as the Qdrant container starts (not waiting for full initialization). The API handles Qdrant connection failures gracefully via the graceful degradation pattern — Qdrant being unavailable results in "qdrant": "not_configured" in /health but does not prevent the service from running.

Docker Compose creates an isolated network where services communicate using service names as hostnames. External clients access the Flask API via localhost port mapping.

Container PortHost PortServiceProtocolPurpose
80018001flask-apiHTTPAutoMem REST API
63796379falkordbTCP (Redis protocol)FalkorDB graph queries
30003000falkordbHTTPFalkorDB built-in web UI
63336333qdrantHTTPQdrant vector search API
30013001falkordb-browserHTTPFalkorDB Browser (optional)

Flask API connects to dependencies using service names:

  • FALKORDB_HOST=falkordb resolves to the falkordb container’s internal IP
  • QDRANT_URL=http://qdrant:6333 resolves to the qdrant container’s internal IP

Docker Compose automatically creates a DNS entry for each service name on the automem_default bridge network. This differs from Railway’s .railway.internal hostnames (see Railway Deployment).

The Makefile provides commands for common Docker Compose operations. These commands handle container lifecycle, testing, and cleanup.

CommandUnderlying ActionPurposeData Loss Risk
make devdocker compose up --buildStart all services, rebuild images if Dockerfile changedNone
make logsdocker compose logs -f flask-apiFollow Flask API logs in real-timeNone
make test-integrationStart services, run pytest with integration tests, keep runningRun full test suite against local Docker stackNone (uses test tokens)
make cleandocker compose down -vStop containers, remove volumesHigh — deletes all memory data
make stopdocker compose downStop containers, preserve volumesNone
Terminal window
make dev

The --build flag ensures the Flask API image is rebuilt if Dockerfile or requirements.txt changed.

Terminal window
make logs
# or for all services:
docker compose logs -f

The make test-integration command orchestrates a full test run:

  1. Starts Docker Compose with test tokens (AUTOMEM_API_TOKEN=test-token, ADMIN_API_TOKEN=test-admin-token)
  2. Waits 5 seconds for service initialization
  3. Runs pytest with AUTOMEM_RUN_INTEGRATION_TESTS=1 environment variable
  4. Leaves services running for debugging
Terminal window
# Stop containers, preserve data volumes:
make stop
# Stop containers AND delete all data volumes:
make clean

The Flask API container mounts the project directory as a volume, enabling hot-reload:

  1. Edit any Python file in the project
  2. Flask detects the change (via FLASK_DEBUG=1)
  3. API automatically reloads within ~2 seconds
  4. No need to restart containers

Docker Compose is optimized for development. Production deployments require security hardening, different persistence strategies, and monitoring.

AspectDocker Compose (Dev)Production Recommendations
Debug ModeFLASK_DEBUG=1, verbose loggingDisable debug, set LOG_LEVEL=INFO or WARNING
API TokensDefaults to test-token, test-admin-tokenGenerate cryptographically secure tokens (32+ chars)
Port ExposureAll ports mapped to localhostUse reverse proxy (nginx, Traefik), expose only necessary ports
Volume BackupsManual exports to ./backups/Automated backups to S3/remote storage (see Backup & Recovery)
Resource LimitsUnlimitedSet deploy.resources.limits in docker-compose.yml
Restart Policyrestart: unless-stoppedUse restart: always with health checks
FalkorDB PersistenceAggressive (save 60 1)Balance between durability and performance
SSL/TLSHTTP onlyTerminate SSL at reverse proxy or use Traefik
MonitoringDocker logsExternal monitoring (Prometheus, health checks)
ScenarioRecommended Deployment
Single developer, local-only accessDocker Compose on local machine
Team collaboration, remote access neededRailway (see Railway Deployment)
Self-hosted production, existing infrastructureDocker Compose with reverse proxy + backups
Prototyping, short-term experimentsDocker Compose (no cloud costs)
Production with minimal ops overheadRailway (managed backups, monitoring)
Air-gapped environments, strict data localityDocker Compose on self-hosted infrastructure
Multi-region deploymentMultiple Railway projects or Kubernetes

Data can be migrated using backup/restore scripts:

  1. Export from Docker Compose:
    Terminal window
    python scripts/backup_automem.py --output ./backups/
  2. Import to Railway:
    • Use GitHub Actions backup workflow to populate Railway from exported snapshots
    • See Backup & Recovery for full restore procedures