How to Install Mem0 on Ubuntu 24.04
A step-by-step installation guide.
Mem0 Installation Guide
Ubuntu 24.04 LTS · Docker
What is Mem0?
Mem0 is a memory layer for AI agents — remembers user preferences, facts, and context across sessions. Gives LLM apps persistent memory without fine-tuning or vector-DB plumbing.
Prerequisites
- 2 CPU (4+ prod) · 2 GB RAM (4 GB+ local embed) · 5 GB+ disk
- Docker ≥ 24.0 + Compose · Port 8083 free · OpenAI key or local LLM
1. Docker Install
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER
2. docker-compose.yml
mkdir -p ~/mem0 && cd ~/mem0
cat > docker-compose.yml << 'EOF'
services:
mem0:
image: mem0ai/mem0:latest
container_name: mem0
restart: unless-stopped
ports:
- "8083:8000"
volumes:
- ./mem0_data:/app/data
environment:
OPENAI_API_KEY: "${OPENAI_API_KEY:-}"
MEM0_EMBEDDING_PROVIDER: "${MEM0_EMBEDDING_PROVIDER:-openai}"
MEM0_CONFIG_PATH: "/app/data/mem0_config.yaml"
MEM0_LOG_LEVEL: "${MEM0_LOG_LEVEL:-info}"
EOF
echo 'OPENAI_API_KEY=*** > .env
3. Launch
docker compose up -d
docker compose logs -f
curl http://localhost:8083/health
4. Nginx Proxy
sudo apt install -y nginx certbot python3-certbot-nginx
Create site proxying 127.0.0.1:8083 with standard headers and proxy_read_timeout 90s:
ln -s /etc/nginx/sites-available/mem0 /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx
certbot --nginx -d mem0.example.com
5. Env Vars
| Var | Req | Def | Description |
|---|---|---|---|
OPENAI_API_KEY | Yes* | — | OpenAI LLM+embed key |
MEM0_EMBEDDING_PROVIDER | No | openai | openai,ollama,sentence-transformers,huggingface |
MEM0_LLM_PROVIDER | No | openai | openai,ollama,anthropic,groq,litellm |
MEM0_GRAPH_STORE | No | None | KG:neo4j,memgraph |
MEM0_VECTOR_STORE | No | Embedded | Vector DB:chromadb,qdrant,pinecone,weaviate |
MEM0_CONFIG_PATH | No | /app/data/conf.yaml | YAML config path |
MEM0_LOG_LEVEL | No | info | debug,info,warning,error |
* Omit with local LLM + local embeddings.
6. Local Embeddings
sentence-transformers
MEM0_EMBEDDING_PROVIDER: "sentence-transformers"
MEM0_EMBEDDING_MODEL: "all-MiniLM-L6-v2"
Ollama
MEM0_EMBEDDING_PROVIDER: "ollama"
MEM0_EMBEDDING_MODEL: "nomic-embed-text"
MEM0_OLLAMA_BASE_URL: "http://host.docker.internal:11434"
Add extra_hosts: ["host.docker.internal:host-gateway"]. ollama pull nomic-embed-text.
7. Backup
cd ~/mem0 && docker compose stop
tar -czf "mem0_$(date +%Y%m%d).tar.gz" mem0_data/
docker compose start
Schedule daily cron backing up ./mem0_data off-machine.
8. Update
cd ~/mem0 && docker compose pull && docker compose up -d --force-recreate
docker image prune -f
9. Troubleshooting
API Key
Symptom: 401. Fix: Check .env, no spaces, enough quota.
Embedding Errors
Symptom: EmbeddingError. Fix: Internet for first download. Ollama running. Increase Nginx timeout.
Retrieval Failing
Symptom: Empty results. Fix: Match embed provider. MEM0_LOG_LEVEL=debug.
Vector DB
Symptom: Connection refused. Fix: Check credentials. docker exec mem0 ping <host>. Data writable.
Mem0 on GitHub · Ubuntu 24.04