|
| 1 | +--- |
| 2 | +layout: '@/layouts/DocsLayout.astro' |
| 3 | +title: 'Docker' |
| 4 | +description: 'Run Basic Memory in Docker containers for server deployments and SSE transport' |
| 5 | +--- |
| 6 | + |
| 7 | +import { Card, CardGroup, Info, Warning, Note, Tip, Steps, Step, CodeGroup, CodeTab } from '@/components' |
| 8 | + |
| 9 | +<Warning> |
| 10 | +The Docker image runs Basic Memory as an **SSE server** on port 8000. This is designed for server deployments where clients connect over HTTP, not for local MCP stdio connections with Claude Desktop. |
| 11 | +</Warning> |
| 12 | + |
| 13 | +## Overview |
| 14 | + |
| 15 | +Basic Memory provides official Docker images published to GitHub Container Registry. The container runs the MCP server with SSE (Server-Sent Events) transport, suitable for: |
| 16 | + |
| 17 | +- Server deployments where multiple clients connect remotely |
| 18 | +- Kubernetes or Docker Compose orchestration |
| 19 | +- CI/CD environments |
| 20 | +- Development and testing |
| 21 | + |
| 22 | +For local use with Claude Desktop or other MCP clients that use stdio transport, we recommend installing via [Homebrew](/getting-started#homebrew-recommended) or [pip](/getting-started#pip-installation). |
| 23 | + |
| 24 | +## Quick Start |
| 25 | + |
| 26 | +### Pull the Image |
| 27 | + |
| 28 | +```bash |
| 29 | +docker pull ghcr.io/basicmachines-co/basic-memory:latest |
| 30 | +``` |
| 31 | + |
| 32 | +### Run the Container |
| 33 | + |
| 34 | +```bash |
| 35 | +docker run -d \ |
| 36 | + --name basic-container \ |
| 37 | + -p 8000:8000 \ |
| 38 | + -v ~/basic-memory-data:/app/data \ |
| 39 | + ghcr.io/basicmachines-co/basic-memory:latest |
| 40 | +``` |
| 41 | + |
| 42 | +The server will be available at `http://localhost:8000/mcp`. |
| 43 | + |
| 44 | +<Note> |
| 45 | +The `-v` flag mounts a local directory for persistent storage. Without it, your data will be lost when the container stops. |
| 46 | +</Note> |
| 47 | + |
| 48 | +## Image Details |
| 49 | + |
| 50 | +### Registry |
| 51 | + |
| 52 | +Images are published to GitHub Container Registry (GHCR): |
| 53 | + |
| 54 | +``` |
| 55 | +ghcr.io/basicmachines-co/basic-memory |
| 56 | +``` |
| 57 | + |
| 58 | +### Available Tags |
| 59 | + |
| 60 | +| Tag | Description | |
| 61 | +|-----|-------------| |
| 62 | +| `latest` | Latest stable release | |
| 63 | +| `0.17.5` | Specific version | |
| 64 | +| `0.17` | Latest patch for minor version | |
| 65 | + |
| 66 | +### Architectures |
| 67 | + |
| 68 | +Multi-platform images are available for: |
| 69 | +- `linux/amd64` (Intel/AMD) |
| 70 | +- `linux/arm64` (Apple Silicon, ARM servers) |
| 71 | + |
| 72 | +Docker automatically pulls the correct architecture for your platform. |
| 73 | + |
| 74 | +## Configuration |
| 75 | + |
| 76 | +### Environment Variables |
| 77 | + |
| 78 | +| Variable | Default | Description | |
| 79 | +|----------|---------|-------------| |
| 80 | +| `BASIC_MEMORY_HOME` | `/app/data/basic-memory` | Path to Basic Memory data | |
| 81 | +| `BASIC_MEMORY_PROJECT_ROOT` | `/app/data` | Root directory for projects | |
| 82 | + |
| 83 | +### Volume Mounts |
| 84 | + |
| 85 | +Mount a local directory to persist data: |
| 86 | + |
| 87 | +```bash |
| 88 | +docker run -d \ |
| 89 | + -v /path/to/local/data:/app/data \ |
| 90 | + -p 8000:8000 \ |
| 91 | + ghcr.io/basicmachines-co/basic-memory:latest |
| 92 | +``` |
| 93 | + |
| 94 | +### Port Configuration |
| 95 | + |
| 96 | +The container exposes port 8000 by default. Map to a different host port if needed: |
| 97 | + |
| 98 | +```bash |
| 99 | +docker run -d \ |
| 100 | + -p 3000:8000 \ |
| 101 | + ghcr.io/basicmachines-co/basic-memory:latest |
| 102 | +``` |
| 103 | + |
| 104 | +## Docker Compose |
| 105 | + |
| 106 | +For more complex setups, use Docker Compose: |
| 107 | + |
| 108 | +```yaml |
| 109 | +version: '3.8' |
| 110 | + |
| 111 | +services: |
| 112 | + basic-container: |
| 113 | + image: ghcr.io/basicmachines-co/basic-memory:latest |
| 114 | + container_name: basic-container |
| 115 | + ports: |
| 116 | + - "8000:8000" |
| 117 | + volumes: |
| 118 | + - ./data:/app/data |
| 119 | + environment: |
| 120 | + - BASIC_MEMORY_HOME=/app/data/basic-memory |
| 121 | + restart: unless-stopped |
| 122 | + healthcheck: |
| 123 | + test: ["CMD", "basic-memory", "--version"] |
| 124 | + interval: 30s |
| 125 | + timeout: 10s |
| 126 | + retries: 3 |
| 127 | +``` |
| 128 | +
|
| 129 | +Run with: |
| 130 | +
|
| 131 | +```bash |
| 132 | +docker compose up -d |
| 133 | +``` |
| 134 | + |
| 135 | +## Connecting to the Server |
| 136 | + |
| 137 | +### MCP SSE Configuration |
| 138 | + |
| 139 | +Configure your MCP client to connect via SSE transport: |
| 140 | + |
| 141 | +```json |
| 142 | +{ |
| 143 | + "mcpServers": { |
| 144 | + "basic-memory": { |
| 145 | + "transport": { |
| 146 | + "type": "sse", |
| 147 | + "url": "http://localhost:8000/mcp" |
| 148 | + } |
| 149 | + } |
| 150 | + } |
| 151 | +} |
| 152 | +``` |
| 153 | + |
| 154 | +### Health Check |
| 155 | + |
| 156 | +Verify the server is running: |
| 157 | + |
| 158 | +```bash |
| 159 | +curl http://localhost:8000/health |
| 160 | +``` |
| 161 | + |
| 162 | +Or check container health: |
| 163 | + |
| 164 | +```bash |
| 165 | +docker inspect --format='{{.State.Health.Status}}' basic-container |
| 166 | +``` |
| 167 | + |
| 168 | +## Running CLI Commands |
| 169 | + |
| 170 | +You can run Basic Memory CLI commands inside the container. Note that the first argument is the container name (`basic-container`) and the second is the CLI command (`basic-memory`): |
| 171 | + |
| 172 | +```bash |
| 173 | +# Check version |
| 174 | +docker exec basic-container basic-memory --version |
| 175 | + |
| 176 | +# Check status |
| 177 | +docker exec basic-container basic-memory status |
| 178 | + |
| 179 | +# List projects |
| 180 | +docker exec basic-container basic-memory project list |
| 181 | +``` |
| 182 | + |
| 183 | +## Security |
| 184 | + |
| 185 | +The container runs as a non-root user (`appuser`) for security. Key security features: |
| 186 | + |
| 187 | +- Non-root execution (UID/GID 1000 by default) |
| 188 | +- No unnecessary packages installed |
| 189 | +- Health checks enabled |
| 190 | +- Slim base image (Python 3.12 slim-bookworm) |
| 191 | + |
| 192 | +### Custom UID/GID |
| 193 | + |
| 194 | +Build with custom user IDs for permission compatibility: |
| 195 | + |
| 196 | +```bash |
| 197 | +docker build --build-arg UID=1001 --build-arg GID=1001 -t basic-memory:custom . |
| 198 | +``` |
| 199 | + |
| 200 | +## Troubleshooting |
| 201 | + |
| 202 | +### Permission Denied Errors |
| 203 | + |
| 204 | +If you see permission errors with mounted volumes: |
| 205 | + |
| 206 | +```bash |
| 207 | +# Fix ownership on host |
| 208 | +sudo chown -R 1000:1000 /path/to/local/data |
| 209 | + |
| 210 | +# Or run with matching UID |
| 211 | +docker run --user $(id -u):$(id -g) ... |
| 212 | +``` |
| 213 | + |
| 214 | +### Container Exits Immediately |
| 215 | + |
| 216 | +Check the logs: |
| 217 | + |
| 218 | +```bash |
| 219 | +docker logs basic-container |
| 220 | +``` |
| 221 | + |
| 222 | +Common causes: |
| 223 | +- Port 8000 already in use |
| 224 | +- Volume mount path doesn't exist |
| 225 | +- Insufficient permissions |
| 226 | + |
| 227 | +### SSE vs Stdio Transport |
| 228 | + |
| 229 | +<Warning> |
| 230 | +The Docker image is configured for SSE transport only. It cannot be used as a stdio MCP server for Claude Desktop directly. |
| 231 | +</Warning> |
| 232 | + |
| 233 | +For Claude Desktop integration, either: |
| 234 | +1. Install Basic Memory locally via Homebrew or pip |
| 235 | +2. Use the SSE transport configuration (if your Claude Desktop version supports it) |
| 236 | + |
| 237 | +## Building from Source |
| 238 | + |
| 239 | +Clone the repository and build locally: |
| 240 | + |
| 241 | +```bash |
| 242 | +git clone https://github.com/basicmachines-co/basic-memory.git |
| 243 | +cd basic-memory |
| 244 | +docker build -t basic-memory:local . |
| 245 | +``` |
| 246 | + |
| 247 | +## See Also |
| 248 | + |
| 249 | +- [Getting Started](/getting-started) - Local installation options |
| 250 | +- [CLI Reference](/guides/cli-reference) - Command line interface |
| 251 | +- [MCP Tools Reference](/guides/mcp-tools-reference) - Available MCP tools |
0 commit comments