Skip to content

Commit 022a699

Browse files
Add comprehensive Docker deployment guide
1 parent ccbe90d commit 022a699

1 file changed

Lines changed: 262 additions & 0 deletions

File tree

DOCKER.md

Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
# Docker Deployment Guide
2+
3+
This guide provides multiple ways to deploy LMStudio-MCP using Docker, depending on your needs and environment.
4+
5+
## Quick Start with Docker
6+
7+
### Option 1: Docker Run (Simplest)
8+
9+
```bash
10+
# Build the image
11+
docker build -t lmstudio-mcp .
12+
13+
# Run the container with host networking (required for LM Studio access)
14+
docker run -it --network host --name lmstudio-mcp-server lmstudio-mcp
15+
```
16+
17+
### Option 2: Docker Compose (Recommended)
18+
19+
```bash
20+
# Start the service
21+
docker-compose up -d
22+
23+
# View logs
24+
docker-compose logs -f lmstudio-mcp
25+
26+
# Stop the service
27+
docker-compose down
28+
```
29+
30+
### Option 3: Pre-built Image from GitHub Container Registry
31+
32+
```bash
33+
# Pull and run the pre-built image
34+
docker run -it --network host --name lmstudio-mcp-server ghcr.io/infinitimeless/lmstudio-mcp:latest
35+
```
36+
37+
## Claude MCP Configuration for Docker
38+
39+
### Method 1: Local Docker Container
40+
41+
```json
42+
{
43+
"lmstudio-mcp-docker": {
44+
"command": "docker",
45+
"args": [
46+
"run",
47+
"-i",
48+
"--rm",
49+
"--network=host",
50+
"lmstudio-mcp"
51+
]
52+
}
53+
}
54+
```
55+
56+
### Method 2: Docker Compose
57+
58+
```json
59+
{
60+
"lmstudio-mcp-compose": {
61+
"command": "docker-compose",
62+
"args": [
63+
"-f", "/path/to/LMStudio-MCP/docker-compose.yml",
64+
"run",
65+
"--rm",
66+
"lmstudio-mcp"
67+
]
68+
}
69+
}
70+
```
71+
72+
### Method 3: Pre-built Image
73+
74+
```json
75+
{
76+
"lmstudio-mcp-ghcr": {
77+
"command": "docker",
78+
"args": [
79+
"run",
80+
"-i",
81+
"--rm",
82+
"--network=host",
83+
"ghcr.io/infinitimeless/lmstudio-mcp:latest"
84+
]
85+
}
86+
}
87+
```
88+
89+
## Advanced Docker Configurations
90+
91+
### Custom Environment Variables
92+
93+
```bash
94+
# Set custom LM Studio URL
95+
docker run -it --network host \
96+
-e LMSTUDIO_API_BASE=http://127.0.0.1:1234/v1 \
97+
lmstudio-mcp
98+
```
99+
100+
### Volume Mounting for Logs
101+
102+
```bash
103+
# Mount logs directory for persistence
104+
docker run -it --network host \
105+
-v $(pwd)/logs:/app/logs \
106+
lmstudio-mcp
107+
```
108+
109+
### Running in Background
110+
111+
```bash
112+
# Run as daemon with restart policy
113+
docker run -d --restart unless-stopped \
114+
--network host \
115+
--name lmstudio-mcp-server \
116+
lmstudio-mcp
117+
```
118+
119+
## Production Deployment
120+
121+
### Using Docker Swarm
122+
123+
```yaml
124+
# docker-stack.yml
125+
version: '3.8'
126+
127+
services:
128+
lmstudio-mcp:
129+
image: ghcr.io/infinitimeless/lmstudio-mcp:latest
130+
deploy:
131+
replicas: 1
132+
restart_policy:
133+
condition: on-failure
134+
delay: 5s
135+
max_attempts: 3
136+
placement:
137+
constraints:
138+
- node.role == manager
139+
networks:
140+
- host
141+
environment:
142+
- LMSTUDIO_API_BASE=http://localhost:1234/v1
143+
144+
networks:
145+
host:
146+
external: true
147+
```
148+
149+
Deploy with:
150+
```bash
151+
docker stack deploy -c docker-stack.yml lmstudio-mcp-stack
152+
```
153+
154+
### Using Kubernetes (Advanced)
155+
156+
```yaml
157+
# k8s-deployment.yml
158+
apiVersion: apps/v1
159+
kind: Deployment
160+
metadata:
161+
name: lmstudio-mcp
162+
labels:
163+
app: lmstudio-mcp
164+
spec:
165+
replicas: 1
166+
selector:
167+
matchLabels:
168+
app: lmstudio-mcp
169+
template:
170+
metadata:
171+
labels:
172+
app: lmstudio-mcp
173+
spec:
174+
hostNetwork: true # Required for LM Studio access
175+
containers:
176+
- name: lmstudio-mcp
177+
image: ghcr.io/infinitimeless/lmstudio-mcp:latest
178+
env:
179+
- name: LMSTUDIO_API_BASE
180+
value: "http://localhost:1234/v1"
181+
stdin: true
182+
tty: true
183+
```
184+
185+
## Troubleshooting Docker Deployment
186+
187+
### Common Issues
188+
189+
1. **Connection refused errors**: Ensure `--network host` is used
190+
2. **Permission denied**: Make sure Docker has proper permissions
191+
3. **LM Studio not accessible**: Verify LM Studio is running on host
192+
193+
### Debugging Commands
194+
195+
```bash
196+
# Check container logs
197+
docker logs lmstudio-mcp-server
198+
199+
# Interactive shell in container
200+
docker exec -it lmstudio-mcp-server bash
201+
202+
# Test connectivity to LM Studio from container
203+
docker run --rm --network host curlimages/curl curl http://localhost:1234/v1/models
204+
```
205+
206+
### Health Checks
207+
208+
```bash
209+
# Check container health status
210+
docker inspect lmstudio-mcp-server | grep -A 10 Health
211+
212+
# Manual health check
213+
docker exec lmstudio-mcp-server python -c "import lmstudio_bridge; print('OK')"
214+
```
215+
216+
## Multi-Architecture Support
217+
218+
The Docker image supports multiple architectures:
219+
- `linux/amd64` (Intel/AMD 64-bit)
220+
- `linux/arm64` (Apple Silicon, ARM64)
221+
222+
Build for specific architecture:
223+
```bash
224+
# For ARM64 (Apple Silicon)
225+
docker buildx build --platform linux/arm64 -t lmstudio-mcp:arm64 .
226+
227+
# For AMD64
228+
docker buildx build --platform linux/amd64 -t lmstudio-mcp:amd64 .
229+
230+
# Multi-platform build
231+
docker buildx build --platform linux/amd64,linux/arm64 -t lmstudio-mcp:latest .
232+
```
233+
234+
## Security Considerations
235+
236+
1. **Network isolation**: The container uses host networking by necessity
237+
2. **Non-root user**: Container runs as non-root user `mcp`
238+
3. **Minimal base image**: Uses Python slim image to reduce attack surface
239+
4. **No persistent data**: Container is stateless by default
240+
241+
## Environment Variables
242+
243+
| Variable | Default | Description |
244+
|----------|---------|-------------|
245+
| `LMSTUDIO_API_BASE` | `http://localhost:1234/v1` | LM Studio API endpoint |
246+
| `LOG_LEVEL` | `INFO` | Logging level |
247+
| `TIMEOUT` | `30` | Request timeout in seconds |
248+
249+
## Performance Tuning
250+
251+
```bash
252+
# Adjust memory limits
253+
docker run -it --network host \
254+
--memory=512m \
255+
--memory-swap=1g \
256+
lmstudio-mcp
257+
258+
# CPU limits
259+
docker run -it --network host \
260+
--cpus="0.5" \
261+
lmstudio-mcp
262+
```

0 commit comments

Comments
 (0)