mcp-server-docker
by: ckreiling
MCP server for Docker
πOverview
Purpose: The MCP server is designed to manage Docker environments using natural language, making container management more intuitive.
Overview: The MCP server allows users to create and manage Docker containers through simple, conversational commands. It is particularly useful for server administrators and hobbyists who want to efficiently handle containers without needing extensive command-line knowledge.
Key Features:
-
Natural Language Composition: Users can define container requirements in plain language, and the server generates and executes Docker configurations based on these instructions.
-
Container Management Tools: The MCP server provides various utilities to list, create, run, and debug containers, images, networks, and volumes, ensuring comprehensive management capabilities.
-
Interactive Planning: Through a plan+apply mechanism, the server enables users to interactively refine and execute their container configurations, enhancing the user experience and flexibility.
π Docker MCP Server
An MCP server for managing Docker with natural language!
πͺ© Features
- π Compose containers with natural language
- π Introspect & debug running containers
- π Manage persistent data with Docker volumes
β Target Users
- Server administrators managing remote Docker engines, e.g., for public-facing websites
- Tinkerers running containers locally and experimenting with Docker apps
- AI enthusiasts exploring LLM capabilities
Demo
A quick demo showing a WordPress deployment using natural language.
ποΈ Quickstart
Install
Claude Desktop Config Paths
- MacOS:
~/Library/Application\ Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%/Claude/claude_desktop_config.json
Install from PyPi with uv
If you don't have uv
installed, follow the installation instructions on its official website.
Add the following to your MCP servers file:
"mcpServers": {
"mcp-server-docker": {
"command": "uvx",
"args": [
"mcp-server-docker"
]
}
}
Install with Docker
This server can run inside a Docker container.
Build the Docker image:
docker build -t mcp-server-docker .
Add the following to your MCP servers file:
"mcpServers": {
"mcp-server-docker": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-v",
"/var/run/docker.sock:/var/run/docker.sock",
"mcp-server-docker:latest"
]
}
}
Note: Mounting the Docker socket allows the MCP server to control the local Docker daemon.
π Prompts
π» docker_compose
Compose containers using natural language. Provide a project name and a description of desired containers, and the LLM will handle the rest.
The prompt instructs the LLM to execute a plan+apply
loop involving:
- You specify containers to bring up.
- The LLM presents a concise natural language plan.
- You either apply the plan or provide feedback to recalculate it.
Examples
-
Name:
nginx
Containers: deploy an nginx container exposing it on port 9000 -
Name:
wordpress
Containers: deploy a WordPress container and a supporting MySQL container, exposing WordPress on port 9000
Resuming a Project
When starting a new chat, the LLM receives the current status of any containers, volumes, and networks associated with the project name, useful for cleanup.
π Resources
The server supports these container resources:
- Stats: CPU, memory, etc.
- Logs: tail container logs
π¨ Tools
Containers
list_containers
create_container
run_container
recreate_container
start_container
fetch_container_logs
stop_container
remove_container
Images
list_images
pull_image
push_image
build_image
remove_image
Networks
list_networks
create_network
remove_network
Volumes
list_volumes
create_volume
remove_volume
π§ Disclaimers
Sensitive Data
DO NOT CONFIGURE CONTAINERS WITH SENSITIVE DATA, such as API keys or database passwords. Exchanging sensitive data with the LLM is insecure unless the LLM runs locally.
If you need secure secrets management, please file an issue with your use case.
Reviewing Created Containers
Docker is not a secure sandbox. The MCP server may impact the host machine. Review all containers created by the LLM carefully.
Sensitive Docker options like --privileged
or --cap-add/--cap-drop
are disabled for safety. Request these features via issues if needed.
π οΈ Configuration
This server uses the Python Docker SDK's from_env
method. For details, see the official Docker SDK documentation.
π» Development
Using Devbox is recommended to configure your development environment.
Example MCP config for Claude MCP with Devbox:
"docker": {
"command": "/path/to/repo/.devbox/nix/profile/default/bin/uv",
"args": [
"--directory",
"/path/to/repo/",
"run",
"mcp-server-docker"
]
}
This document provides a clear overview and usage guide for the Docker MCP server with unnecessary details and local links removed.