How to Set Up Mem0 with Docker: Complete Installation and Deployment Guide
Deploy Mem0 (OpenMemory) using a single cURL command that generates a tailored Docker Compose configuration, automatically provisioning the Memory Control Plane on port 8765, a persistent vector store, and a React UI while handling environment variables and dependency wiring.
Setting up Mem0 with Docker provides a self-hosted, privacy-preserving memory layer for LLM applications. The official mem0ai/mem0 repository includes the automated installer script openmemory/run.sh and modular compose fragments that configure the entire stack—including the Memory Control Plane API, vector database, and frontend UI—based on your chosen backend.
One-Line Docker Installation
The quickest way to set up Mem0 with Docker is using the official installer script hosted in the repository. This script orchestrates the entire deployment by checking prerequisites, selecting available ports, and generating a customized docker-compose.yml file.
Run the following command, replacing <your_key> with your OpenAI API key:
curl -sL https://raw.githubusercontent.com/mem0ai/mem0/main/openmemory/run.sh \
| OPENAI_API_KEY=<your_key> bash
The installer performs several critical actions defined in openmemory/run.sh:
- Verifies Docker and Docker Compose v2 are installed.
- Selects the first available host port between 3000 and 3010 for the UI.
- Exports required environment variables including
OPENAI_API_KEY,USER, andNEXT_PUBLIC_API_URL. - Generates a
docker-compose.ymlby merging your chosen vector-store configuration (defaulting to Qdrant fromopenmemory/compose/qdrant.yml) with the MCP service definition. - Starts the backend containers and installs the appropriate Python client for the selected vector store inside the MCP container.
- Persists the vector-store configuration via HTTP PUT to the MCP API.
- Launches the UI container and opens the interface in your browser.
Container Architecture Overview
The Mem0 Docker deployment consists of three primary services orchestrated within a dedicated bridge network (mem0_network by default). All data persists across container restarts using Docker-named volumes.
Memory Control Plane (MCP)
The MCP (mem0/openmemory-mcp:latest) is the core FastAPI backend defined in openmemory/api/Dockerfile. It runs Uvicorn with hot-reload enabled for development (uvicorn main:app --host 0.0.0.0 --port 8000 --reload), though the compose file exposes it externally on port 8765. The service mounts the openmemory_db volume for SQLite history storage and depends on the vector store container (unless using FAISS).
Vector Store Backend
The vector database stores embeddings and is selected via the --vector-store flag. The installer merges the appropriate fragment from openmemory/compose/ (e.g., qdrant.yml, chroma.yml) into the final compose file. Each backend injects specific environment variables into the MCP container:
- Qdrant (
openmemory/compose/qdrant.yml): Default option. InjectsQDRANT_HOSTandQDRANT_PORT. - Chroma (
openmemory/compose/chroma.yml): InjectsCHROMA_HOSTandCHROMA_PORT. - Weaviate (
openmemory/compose/weaviate.yml): InjectsWEAVIATE_HOSTandWEAVIATE_PORT. - Redis (
openmemory/compose/redis.yml): InjectsREDIS_URL. - PGVector (
openmemory/compose/pgvector.yml): InjectsPG_HOST,PG_PORT, and related credentials. - Milvus (
openmemory/compose/milvus.yml): InjectsMILVUS_HOSTandMILVUS_PORT. - Elasticsearch (
openmemory/compose/elasticsearch.yml): InjectsELASTICSEARCH_HOSTandELASTICSEARCH_PORT. - FAISS: Local file-based storage requiring no separate container; mounts
FAISS_PATHas a volume.
All vector store containers connect via the internal Docker DNS name mem0_store.
Frontend UI
The React UI (mem0/openmemory-ui:latest) is built from openmemory/ui/Dockerfile and requires two build-time environment variables: NEXT_PUBLIC_API_URL (pointing to the MCP) and NEXT_PUBLIC_USER_ID. The installer automatically assigns the first free port in the 3000-3010 range, mapping it to the container's internal port.
Deployment Considerations
When moving from quick-start to production, several factors require attention to ensure security, stability, and performance.
Port Management and Exposure
The MCP always binds to port 8765 on the host. The UI dynamically selects ports 3000-3010 to avoid conflicts. Override the frontend port by setting FRONTEND_PORT before running the installer, or modify the generated docker-compose.yml to publish custom ports for external access.
Data Persistence Strategy
The deployment uses Docker-named volumes (openmemory_db for SQLite history and mem0_storage or store-specific volumes for vector indexes) to ensure data survives container recreation. For production deployments, implement automated backup strategies using docker volume export or volume mounts to host directories for easier snapshotting.
Security and Secrets Management
The OPENAI_API_KEY is passed as a plaintext environment variable to the MCP container. For production environments, treat the Docker host as a trusted boundary or migrate secrets to Docker Secrets (Swarm mode) or an external secret manager. Consider using an .env file referenced via env_file: in docker-compose.yml instead of inline environment variables.
Resource Allocation
Vector stores like Qdrant and Milvus are memory-intensive and may require significant RAM and CPU depending on embedding dimensions and dataset size. Allocate sufficient resources in Docker Desktop or your daemon configuration, and monitor usage with docker stats during initial indexing operations.
Networking and Isolation
All services communicate over the isolated mem0_network bridge. If exposing services to external networks, ensure only necessary ports (typically just the UI port and optionally 8765 for API access) are published. Avoid exposing vector store ports publicly unless specifically required for external tooling.
Scalability and High Availability
The MCP service is stateless and can be scaled horizontally behind a reverse proxy if you remove the embedded SQLite dependency or externalize the database. Vector stores have varying clustering capabilities—Qdrant versions 1.8+ support multi-node deployment, while others like Chroma or FAISS require external solutions for horizontal scaling.
Health Checks and Monitoring
The development stack in server/docker-compose.yaml includes health checks for PostgreSQL and Neo4j. Add similar healthcheck: definitions to your production vector store and MCP services to ensure dependent containers start only when dependencies are ready. Monitor logs using docker compose logs -f <service>.
Upgrade Path
Update the stack by pulling new image tags and recreating containers:
docker compose pull
docker compose up -d --force-recreate
This ensures you receive the latest mem0/openmemory-mcp:latest and mem0/openmemory-ui:latest images without losing persisted volume data.
Custom Vector Store Configuration
To deploy with a non-default backend, specify the store name as an argument:
curl -sL https://raw.githubusercontent.com/mem0ai/mem0/main/openmemory/run.sh \
| OPENAI_API_KEY=<key> bash --vector-store=weaviate
The script selects the corresponding file from openmemory/compose/, installs the required Python client inside the MCP container, and configures the connection parameters automatically.
Development Environment
For contributing to the core mem0 Python library alongside OpenMemory, use the separate development stack defined in server/docker-compose.yaml. This configuration builds the package in editable mode (pip install -e .[graph]) using server/dev.Dockerfile and includes PostgreSQL and Neo4j for testing graph-aware features.
Summary
- One-command setup: Use the
openmemory/run.shinstaller with yourOPENAI_API_KEYto generate and start the complete stack. - Modular architecture: The deployment consists of the MCP API (port 8765), a selectable vector store (
mem0_store), and a React UI (ports 3000-3010). - Persistent storage: Data survives container restarts via named volumes; implement backup strategies for production.
- Security: Manage the
OPENAI_API_KEYcarefully; use.envfiles or Docker secrets instead of inline exports for production. - Resource aware: Vector stores require significant RAM; monitor resource allocation during deployment.
- Update method: Use
docker compose pullandup -dto upgrade images while preserving data volumes.
Frequently Asked Questions
How do I change the default port for the Mem0 web interface?
The installer script automatically selects the first available port between 3000 and 3010 to avoid conflicts. To specify a custom port, export the FRONTEND_PORT environment variable before running the installer (e.g., export FRONTEND_PORT=8080), or manually edit the ports section in the generated docker-compose.yml file to map your preferred host port to the container.
Can I use a different vector database like Chroma or Weaviate instead of Qdrant?
Yes. Pass the --vector-store flag with the desired backend name when executing the installer script. For example, append --vector-store=chroma or --vector-store=weaviate to the bash command. The script automatically merges the appropriate compose fragment from openmemory/compose/, installs the required Python client, and configures the necessary environment variables for the MCP to connect.
Where is my data stored when using Mem0 with Docker?
Data persists in Docker-named volumes. The MCP uses openmemory_db for SQLite history, while vector stores use dedicated volumes (e.g., mem0_storage for Qdrant or FAISS_PATH for local FAISS indexes). These volumes survive container removal and recreation. For production, back up these volumes regularly using docker volume export or mount host directories for easier file-system access.
How do I update my Mem0 Docker deployment to the latest version?
Run docker compose pull to fetch the latest mem0/openmemory-mcp:latest and mem0/openmemory-ui:latest images, then execute docker compose up -d --force-recreate to restart the containers. Your data remains intact because it resides in persistent Docker volumes that are not affected by image updates or container recreation.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →