loading…
Search for a command to run...
loading…
MCP server for executing commands in Docker containers
MCP server for executing commands in Docker containers
This MCP (Model Context Protocol) server provides a secure interface for running commands inside Docker containers. It acts as a privileged sidecar that can execute arbitrary commands within specified Docker Compose service containers.
Run the MCP server directly without cloning:
npx mcp-server-docker
Or install globally:
npm install -g mcp-server-docker
mcp-server-docker
Add the following to your docker-compose.yml:
services:
mcp-docker:
build: ./mcp-server-docker
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- "3001:3000" # Expose MCP server
environment:
- COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}
- DEFAULT_SERVICE=app
- COMPOSE_FILE=docker-compose.yml
- PORT=3000
networks:
- your-network
cd mcp-server-docker
npm install
npm run build
The server accepts the following environment variables:
ALLOWED_CONTAINERS: Comma-separated list of allowed service:container pairs (e.g., "app:myapp_container,db:mydb_container")DEFAULT_SERVICE: Default service to run commands in (default: "laravel_app")COMMAND_TIMEOUT: Command timeout in milliseconds (default: 300000)The server exposes a single tool called run_command:
{
"command": "string (required) - The command to execute",
"service": "string (optional) - Docker service name"
}
{
"command": "npm test",
"service": "frontend"
}
The tool returns the command output with the following structure:
The server uses STDIO transport for MCP communication. When run with npx mcp-server-docker, it will:
# Run in development mode
npm run dev
# Build TypeScript
npm run build
# Run tests
npm test
Add this to claude_desktop_config.json and restart Claude Desktop.
{
"mcpServers": {
"docker": {
"command": "npx",
"args": [
"-y",
"mcp-server-docker"
]
}
}
}pro tip
Just installed Docker? Say to Claude: "remember why I installed Dockerand what I want to try" — it'll save into your Vault.