Back to articles
AI & Cloud

Self-Host Mem0 on Docker VPS: Create Personalized Long-Term Memory for AI Agent Systems

A detailed guide on self-hosting Mem0 on Docker VPS to create personalized long-term memory, optimizing AI agent system performance. Covers configuration, installation,...

DPTCloud Engineering4 min read
Self-Host Mem0 on Docker VPS: Create Personalized Long-Term Memory for AI Agent Systems

Create Personalized Long-Term Memory for AI Agents with Mem0 on Docker VPS

In today's rapidly evolving AI landscape, maintaining long-term memory for AI agents is essential for ensuring performance, consistency, and continuous learning. Mem0 is a self-hosted solution that enables AI agents to store and retrieve contextual information, supporting personalized tasks. This guide shows you how to self-host Mem0 on a Docker VPS to create a personalized long-term memory, optimizing the performance of your AI agent system.

Prerequisites Before Starting

  • Run a VPS with at least 4GB RAM and 2 CPU cores.
  • Have Docker and Docker Compose installed.
  • Have root or sudo access on the VPS.
  • Have a domain or subdomain for accessing Mem0 (optional but recommended).

Install Mem0 on Docker VPS

To self-host Mem0, you need to create a docker-compose.yml file to define the required services. Below is a basic configuration:

version: '3.8'

services:
  mem0:
    image: mem0/mem0:latest
    container_name: mem0
    ports:
      - "8080:8080"
    volumes:
      - ./data:/data
    environment:
      - MEM0_API_KEY=your_secret_api_key
      - MEM0_STORAGE_TYPE=local
    restart: unless-stopped

Run the following command to start the service:

docker-compose up -d

Mem0 will run on port 8080. You can access the web interface at http://:8080.

Customize Personalized Long-Term Memory

Mem0 allows you to personalize long-term memory by defining contexts and storing information by topic. For example, you can create contexts such as:

  • Work: Store information about work, projects, and emails.
  • Personal: Store personal schedules, hobbies, and notes.
  • AI Agent: Store commands, behaviors, and feedback from AI agents.

To add a context, you can use Mem0's API or web interface to input data. For instance, to add a note to the "Work" context, you can send an HTTP request:

POST /api/v1/contexts/work/notes
Content-Type: application/json
Authorization: Bearer your_secret_api_key

{
  "title": "Meeting with Client",
  "content": "Discussed project timeline and budget."
}

Verify and Test Activity

After installation, verify Mem0 is working correctly by:

  1. Accessing http://:8080 to view the web interface.
  2. Adding a note to a context.
  3. Querying the note to check consistency.

To verify via CLI, you can use the cURL command:

curl -X GET http://:8080/api/v1/contexts/work/notes \
  -H "Authorization: Bearer your_secret_api_key"

Troubleshooting

  • Cannot access Mem0: Check if Docker is running and if port 8080 is blocked by a firewall.
  • Cannot save data: Check if the ./data directory has write permissions. Ensure the volume is correctly mounted.
  • API Key not working: Verify the MEM0_API_KEY environment variable in the docker-compose.yml file.

References

DPTCloud Tier III Infrastructure

High-RAM Cloud VPS Plans Optimized for AI, Databases & Cache

Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.

View 22 VPS Plans
ECO · vn-02Recommended

VPS-4E

297.000 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe
ECO · vn-02

VPS-5E

614.900 ₫ / mo

10% VAT included

  • CPU: 8 vCPU
  • RAM: 16 GB
  • SSD: 100 GB NVMe
ADVANCED · vn-03Recommended

VPS-4T

548.900 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe

Related Articles

View all
ZaloZalo SupportDiscord0384 753 478