Overview
Manage Docker containers, images, networks, and volumes from AI agents.
Setup
Run with npx:
npx -y @modelcontextprotocol/server-dockerConfiguration
Docker socket access requiredDocumentation
Docker MCP
Overview
Docker MCP provides direct access to Docker, enabling AI agents to manage containers, images, networks, and volumes. Perfect for container debugging, development workflows, and managing Docker-based infrastructure.
Features
- Container Management: Run, stop, start, restart, and remove containers
- Image Operations: Pull, build, list, and remove Docker images
- Log Access: View container logs in real-time
- Exec Commands: Run commands inside running containers
- Network Management: List and manage Docker networks
- Volume Management: List, create, and remove volumes
- System Info: Get Docker system information and events
Installation
npx -y @modelcontextprotocol/server-docker
Configuration
Add to your Claude Desktop config:
{
"mcpServers": {
"docker": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-docker"]
}
}
}
Permission Requirements
The MCP server needs access to the Docker socket. On Linux, this typically requires adding your user to the docker group:
sudo usermod -aG docker $USER
newgrp docker
On macOS (with Docker Desktop), the socket is available by default.
Available Tools
| Tool | Description |
|---|---|
list_containers | List running containers |
create_container | Create a new container |
start_container | Start a stopped container |
stop_container | Stop a running container |
remove_container | Remove a container |
exec_container | Run a command in a container |
logs_container | Get container logs |
list_images | List Docker images |
pull_image | Pull a Docker image |
build_image | Build an image from Dockerfile |
remove_image | Remove a Docker image |
list_networks | List Docker networks |
list_volumes | List Docker volumes |
system_info | Get Docker system information |
Usage Examples
Container Management
List all running containers
Stop container "my-app-1"
Start container "my-app-1"
Remove container "old-container"
Run Commands in Containers
Execute "ls -la" in container "my-app-1"
Execute "npm test" in container "my-app-1"
View Logs
Get last 100 lines of logs from container "my-app-1"
Follow logs from container "my-app-1" (real-time)
Image Operations
List all Docker images
Pull image "nginx:latest"
Build image from Dockerfile in current directory
Run a New Container
Run container from image "python:3.11" with command "python app.py"
Run container "redis" with port mapping 6379:6379
Claude Desktop Setup
- Ensure Docker is running
- Install the MCP server
- Add configuration to
claude_desktop_config.json - Restart Claude Desktop
- The Docker tool will appear in your available tools
Security Considerations
- Docker socket access gives root-equivalent privileges
- Only enable Docker MCP on trusted development machines
- Consider using read-only access for inspection-only workflows
- Be cautious when executing commands in containers
Pros
- ✅ Full Docker CLI functionality
- ✅ Great for container debugging
- ✅ Can run and manage containers directly
- ✅ Real-time log access
- ✅ No additional dependencies
Cons
- ❌ Requires Docker to be installed and running
- ❌ Docker socket access is powerful (security consideration)
- ❌ No built-in Docker Compose support
- ❌ Container operations can affect local development
