This guide provides multiple ways to deploy LMStudio-MCP using Docker, depending on your needs and environment.
# Build the image
docker build -t lmstudio-mcp .
# Run the container with host networking (required for LM Studio access)
docker run -it --network host --name lmstudio-mcp-server lmstudio-mcp# Start the service
docker-compose up -d
# View logs
docker-compose logs -f lmstudio-mcp
# Stop the service
docker-compose down# Pull and run the pre-built image
docker run -it --network host --name lmstudio-mcp-server ghcr.io/infinitimeless/lmstudio-mcp:latest{
"lmstudio-mcp-docker": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--network=host",
"lmstudio-mcp"
]
}
}{
"lmstudio-mcp-compose": {
"command": "docker-compose",
"args": [
"-f", "/path/to/LMStudio-MCP/docker-compose.yml",
"run",
"--rm",
"lmstudio-mcp"
]
}
}{
"lmstudio-mcp-ghcr": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--network=host",
"ghcr.io/infinitimeless/lmstudio-mcp:latest"
]
}
}# Set custom LM Studio URL
docker run -it --network host \
-e LMSTUDIO_API_BASE=http://127.0.0.1:1234/v1 \
lmstudio-mcp# Mount logs directory for persistence
docker run -it --network host \
-v $(pwd)/logs:/app/logs \
lmstudio-mcp# Run as daemon with restart policy
docker run -d --restart unless-stopped \
--network host \
--name lmstudio-mcp-server \
lmstudio-mcp# docker-stack.yml
version: '3.8'
services:
lmstudio-mcp:
image: ghcr.io/infinitimeless/lmstudio-mcp:latest
deploy:
replicas: 1
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
placement:
constraints:
- node.role == manager
networks:
- host
environment:
- LMSTUDIO_API_BASE=http://localhost:1234/v1
networks:
host:
external: trueDeploy with:
docker stack deploy -c docker-stack.yml lmstudio-mcp-stack# k8s-deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: lmstudio-mcp
labels:
app: lmstudio-mcp
spec:
replicas: 1
selector:
matchLabels:
app: lmstudio-mcp
template:
metadata:
labels:
app: lmstudio-mcp
spec:
hostNetwork: true # Required for LM Studio access
containers:
- name: lmstudio-mcp
image: ghcr.io/infinitimeless/lmstudio-mcp:latest
env:
- name: LMSTUDIO_API_BASE
value: "http://localhost:1234/v1"
stdin: true
tty: true- Connection refused errors: Ensure
--network hostis used - Permission denied: Make sure Docker has proper permissions
- LM Studio not accessible: Verify LM Studio is running on host
# Check container logs
docker logs lmstudio-mcp-server
# Interactive shell in container
docker exec -it lmstudio-mcp-server bash
# Test connectivity to LM Studio from container
docker run --rm --network host curlimages/curl curl http://localhost:1234/v1/models# Check container health status
docker inspect lmstudio-mcp-server | grep -A 10 Health
# Manual health check
docker exec lmstudio-mcp-server python -c "import lmstudio_bridge; print('OK')"The Docker image supports multiple architectures:
linux/amd64(Intel/AMD 64-bit)linux/arm64(Apple Silicon, ARM64)
Build for specific architecture:
# For ARM64 (Apple Silicon)
docker buildx build --platform linux/arm64 -t lmstudio-mcp:arm64 .
# For AMD64
docker buildx build --platform linux/amd64 -t lmstudio-mcp:amd64 .
# Multi-platform build
docker buildx build --platform linux/amd64,linux/arm64 -t lmstudio-mcp:latest .- Network isolation: The container uses host networking by necessity
- Non-root user: Container runs as non-root user
mcp - Minimal base image: Uses Python slim image to reduce attack surface
- No persistent data: Container is stateless by default
| Variable | Default | Description |
|---|---|---|
LMSTUDIO_API_BASE |
http://localhost:1234/v1 |
LM Studio API endpoint |
LOG_LEVEL |
INFO |
Logging level |
TIMEOUT |
30 |
Request timeout in seconds |
# Adjust memory limits
docker run -it --network host \
--memory=512m \
--memory-swap=1g \
lmstudio-mcp
# CPU limits
docker run -it --network host \
--cpus="0.5" \
lmstudio-mcp