记忆机器的持久化

Docker部署的MemMachine,用起来很满意,今天改一下持久化的位置

在容器开启的情况下执行,分开执行是因为两个命令都需要sudo

1
2
CONTAINER_IDS=$(sudo docker ps -q)
sudo docker inspect $CONTAINER_IDS --format='{{printf "\n=== %s ===" .Name}}{\n%-8s %-40s -> %s" .Type .Source .Destination}}{{end}}'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
=== /memmachine-app ===
bind /vol1/1000/mSATA-SSD/Docker/MemM/configuration.yml -> /app/configuration.yml
volume /vol1/docker/volumes/memmachine_memmachine_logs/_data -> /tmp/memory_logs

=== /memmachine-neo4j ===
volume /vol1/docker/volumes/memmachine_neo4j_plugins/_data -> /plugins
volume /vol1/docker/volumes/memmachine_neo4j_data/_data -> /data
volume /vol1/docker/volumes/memmachine_neo4j_logs/_data -> /logs
volume /vol1/docker/volumes/memmachine_neo4j_import/_data -> /var/lib/neo4j/import

=== /memmachine-postgres ===
volume /vol1/docker/volumes/memmachine_postgres_data/_data -> /var/lib/postgresql/data

=== /memmachine-docs-1 ===
bind /vol1/1000/mSATA-SSD/Docker/MemM/docs -> /docs

=== /astrbot ===
bind /vol1/1000/mSATA-SSD/Docker/AstrBot/data -> /AstrBot/data
bind /etc/localtime -> /etc/localtime
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 先创建目标目录
mkdir -p /home/zhaosn/XXMemory

# 保留原始文件夹名 完整复制
cp -av /vol1/1000/mSATA-SSD/Docker/MemM/configuration.yml /home/zhaosn/XXMemory/
cp -av /vol1/docker/volumes/memmachine_memmachine_logs /home/zhaosn/XXMemory/

cp -av /vol1/docker/volumes/memmachine_neo4j_plugins /home/zhaosn/XXMemory/
cp -av /vol1/docker/volumes/memmachine_neo4j_data /home/zhaosn/XXMemory/
cp -av /vol1/docker/volumes/memmachine_neo4j_logs /home/zhaosn/XXMemory/
cp -av /vol1/docker/volumes/memmachine_neo4j_import /home/zhaosn/XXMemory/

cp -av /vol1/docker/volumes/memmachine_postgres_data /home/zhaosn/XXMemory/

cp -av /vol1/1000/mSATA-SSD/Docker/MemM/docs /home/zhaosn/XXMemory/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
services:
# PostgreSQL with pgvector extension for profile memory storage
postgres:
image: pgvector/pgvector:pg16
container_name: memmachine-postgres
restart: unless-stopped
environment:
POSTGRES_DB: ${POSTGRES_DB:-memmachine}
POSTGRES_USER: ${POSTGRES_USER:-memmachine}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-memmachine_password}
POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --lc-collate=C --lc-ctype=C"
volumes:
- ./memmachine_postgres_data/_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-memmachine} -d ${POSTGRES_DB:-memmachine}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
networks:
- memmachine-network

# Neo4j database for graph storage
neo4j:
image: neo4j:5.23-community
container_name: memmachine-neo4j
restart: unless-stopped
environment:
NEO4J_EDITION: community
NEO4J_AUTH: ${NEO4J_USER:-neo4j}/${NEO4J_PASSWORD:-neo4j_password}
NEO4J_server_bolt_thread__pool__max__size: 2000
NEO4J_server_memory_heap_initial__size: 512m
NEO4J_server_memory_heap_max__size: 1G
NEO4J_server_default__listen__address: 0.0.0.0
NEO4J_server_bolt_listen__address: 0.0.0.0:7687
NEO4J_server_http_listen__address: 0.0.0.0:7474
NEO4J_server_https_listen__address: 0.0.0.0:7473
NEO4J_PLUGINS: '["apoc", "graph-data-science"]'
volumes:
- ./memmachine_neo4j_data/_data:/data
- ./memmachine_neo4j_logs/_data:/logs
- ./memmachine_neo4j_import/_data:/var/lib/neo4j/import
- ./memmachine_neo4j_plugins/_data:/plugins
healthcheck:
test: ["CMD", "cypher-shell", "-u", "${NEO4J_USER:-neo4j}", "-p", "${NEO4J_PASSWORD:-neo4j_password}", "RETURN 1"]
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
networks:
- memmachine-network

# MemMachine application
memmachine:
image: ${MEMMACHINE_IMAGE:-memmachine/memmachine}
pull_policy: ${PULL_POLICY:-always}
container_name: memmachine-app
restart: unless-stopped
ports:
- "${MEMORY_SERVER_PORT:-8080}:8080"
environment:
# Database configuration
POSTGRES_HOST: ${POSTGRES_HOST:-postgres}
POSTGRES_PORT: ${POSTGRES_PORT:-5432}
POSTGRES_USER: ${POSTGRES_USER:-memmachine}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-memmachine_password}
POSTGRES_DB: ${POSTGRES_DB:-memmachine}

# Neo4j configuration
NEO4J_HOST: ${NEO4J_HOST:-neo4j}
NEO4J_PORT: ${NEO4J_PORT:-7687}
NEO4J_USER: ${NEO4J_USER:-neo4j}
NEO4J_PASSWORD: ${NEO4J_PASSWORD:-neo4j_password}

# Application configuration
MEMORY_CONFIG: ${MEMORY_CONFIG:-/app/configuration.yml}
MCP_BASE_URL: ${MCP_BASE_URL:-http://memmachine:8080}
GATEWAY_URL: ${GATEWAY_URL:-http://localhost:8080}
FAST_MCP_LOG_LEVEL: ${FAST_MCP_LOG_LEVEL:-INFO}
OPENAI_API_KEY: ${OPENAI_API_KEY:-}
MEMMACHINE_WORKERS: ${MEMMACHINE_WORKERS:-1}
MEMMACHINE_CONFIG_API: ${MEMMACHINE_CONFIG_API:-}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
HOST: 0.0.0.0
volumes:
- ./configuration.yml:/app/configuration.yml:rw,Z
- memmachine_logs:/tmp/memory_logs
depends_on:
postgres:
condition: service_healthy
neo4j:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "--fail", "--silent", "http://localhost:8080/api/v2/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
networks:
- memmachine-network
extra_hosts:
- "host.docker.internal:host-gateway"

docs:
container_name: memmachine-docs
build:
context: docs/
dockerfile: Dockerfile
ports:
- "${DOCS_PORT:-3000}:3000"
volumes:
- ./docs:/docs:ro,Z

volumes:
memmachine_logs:
driver: local

networks:
memmachine-network:
driver: bridge
name: memmachine-network

记忆机器的持久化
https://blog.zhaosn.top/Joi-memory/
作者
Zhao SN
发布于
2026年4月9日
更新于
2026年4月9日
许可协议