$git clone https://github.com/ckreiling/mcp-server-dockerAn MCP server for managing Docker with natural language!
| 1 | # 🐋 Docker MCP server |
| 2 | |
| 3 | An MCP server for managing Docker with natural language! |
| 4 | |
| 5 | ## 🪩 What can it do? |
| 6 | |
| 7 | - 🚀 Compose containers with natural language |
| 8 | - 🔍 Introspect & debug running containers |
| 9 | - 📀 Manage persistent data with Docker volumes |
| 10 | |
| 11 | ## ❓ Who is this for? |
| 12 | |
| 13 | - Server administrators: connect to remote Docker engines for e.g. managing a |
| 14 | public-facing website. |
| 15 | - Tinkerers: run containers locally and experiment with open-source apps |
| 16 | supporting Docker. |
| 17 | - AI enthusiasts: push the limits of that an LLM is capable of! |
| 18 | |
| 19 | ## Demo |
| 20 | |
| 21 | A quick demo showing a WordPress deployment using natural language: |
| 22 | |
| 23 | https://github.com/user-attachments/assets/65e35e67-bce0-4449-af7e-9f4dd773b4b3 |
| 24 | |
| 25 | ## 🏎️ Quickstart |
| 26 | |
| 27 | ### Install |
| 28 | |
| 29 | #### Claude Desktop |
| 30 | |
| 31 | On MacOS: `~/Library/Application\ Support/Claude/claude_desktop_config.json` |
| 32 | |
| 33 | On Windows: `%APPDATA%/Claude/claude_desktop_config.json` |
| 34 | |
| 35 | <details> |
| 36 | <summary>Install from PyPi with uv</summary> |
| 37 | |
| 38 | If you don't have `uv` installed, follow the installation instructions for your |
| 39 | system: |
| 40 | [link](https://docs.astral.sh/uv/getting-started/installation/#installation-methods) |
| 41 | |
| 42 | Then add the following to your MCP servers file: |
| 43 | |
| 44 | ``` |
| 45 | "mcpServers": { |
| 46 | "mcp-server-docker": { |
| 47 | "command": "uvx", |
| 48 | "args": [ |
| 49 | "mcp-server-docker" |
| 50 | ] |
| 51 | } |
| 52 | } |
| 53 | ``` |
| 54 | |
| 55 | </details> |
| 56 | |
| 57 | <details> |
| 58 | <summary>Install with Docker</summary> |
| 59 | |
| 60 | Purely for convenience, the server can run in a Docker container. |
| 61 | |
| 62 | After cloning this repository, build the Docker image: |
| 63 | |
| 64 | ```bash |
| 65 | docker build -t mcp-server-docker . |
| 66 | ``` |
| 67 | |
| 68 | And then add the following to your MCP servers file: |
| 69 | |
| 70 | ``` |
| 71 | "mcpServers": { |
| 72 | "mcp-server-docker": { |
| 73 | "command": "docker", |
| 74 | "args": [ |
| 75 | "run", |
| 76 | "-i", |
| 77 | "--rm", |
| 78 | "-v", |
| 79 | "/var/run/docker.sock:/var/run/docker.sock", |
| 80 | "mcp-server-docker:latest" |
| 81 | ] |
| 82 | } |
| 83 | } |
| 84 | ``` |
| 85 | |
| 86 | Note that we mount the Docker socket as a volume; this ensures the MCP server |
| 87 | can connect to and control the local Docker daemon. |
| 88 | |
| 89 | </details> |
| 90 | |
| 91 | ## 📝 Prompts |
| 92 | |
| 93 | ### 🎻 `docker_compose` |
| 94 | |
| 95 | Use natural language to compose containers. [See above](#demo) for a demo. |
| 96 | |
| 97 | Provide a Project Name, and a description of desired containers, and let the LLM |
| 98 | do the rest. |
| 99 | |
| 100 | This prompt instructs the LLM to enter a `plan+apply` loop. Your interaction |
| 101 | with the LLM will involve the following steps: |
| 102 | |
| 103 | 1. You give the LLM instructions for which containers to bring up |
| 104 | 2. The LLM calculates a concise natural language plan and presents it to you |
| 105 | 3. You either: |
| 106 | - Apply the plan |
| 107 | - Provide the LLM feedback, and the LLM recalculates the plan |
| 108 | |
| 109 | #### Examples |
| 110 | |
| 111 | - name: `nginx`, containers: "deploy an nginx container exposing it on port |
| 112 | 9000" |
| 113 | - name: `wordpress`, containers: "deploy a WordPress container and a supporting |
| 114 | MySQL container, exposing Wordpress on port 9000" |
| 115 | |
| 116 | #### Resuming a Project |
| 117 | |
| 118 | When starting a new chat with this prompt, the LLM will receive the status of |
| 119 | any containers, volumes, and networks created with the given project `name`. |
| 120 | |
| 121 | This is mainly useful for cleaning up, in-case you lose a chat that was |
| 122 | responsible for many containers. |
| 123 | |
| 124 | ## 📔 Resources |
| 125 | |
| 126 | The server implements a couple resources for every container: |
| 127 | |
| 128 | - Stats: CPU, memory, etc. for a container |
| 129 | - Logs: tail some logs from a container |
| 130 | |
| 131 | ## 🔨 Tools |
| 132 | |
| 133 | ### Containers |
| 134 | |
| 135 | - `list_containers` |
| 136 | - `create_container` |
| 137 | - `run_container` |
| 138 | - `recreate_container` |
| 139 | - `start_container` |
| 140 | - `fetch_container_logs` |
| 141 | - `stop_container` |
| 142 | - `remove_container` |
| 143 | |
| 144 | ### Images |
| 145 | |
| 146 | - `list_images` |
| 147 | - `pull_image` |
| 148 | - `push_image` |
| 149 | - `build_image` |
| 150 | - `remove_image` |
| 151 | |
| 152 | ### Networks |
| 153 | |
| 154 | - `list_networks` |
| 155 | - `create_network` |
| 156 | - `remove_network` |
| 157 | |
| 158 | ### Volumes |
| 159 | |
| 160 | - `list_volumes` |
| 161 | - `create_volume` |
| 162 | - `remove_volume` |
| 163 | |
| 164 | ## 🚧 Disclaimers |
| 165 | |
| 166 | ### Sensitive Data |
| 167 | |
| 168 | **DO NOT CONFIGURE CONTAINERS WITH SENSITIVE DATA.** This includes API keys, |
| 169 | database passwords, etc. |
| 170 | |
| 171 | Any sensitive data exchanged with the LLM is inherently compromised, unless the |
| 172 | LLM is running on your local machine. |
| 173 | |
| 174 | If you are interested in securely passing secrets to containers, file an issue |
| 175 | on this repository |