Skip to main content
Glama
Isak-Landin

Docker MCP

by Isak-Landin

Docker MCP

通过 SSH 进行远程 Docker 管理 — 作为本地 MCP 服务器暴露给 GitHub Copilot 会话。

无需服务器端组件。MCP 在本地运行,并通过 SSH 连接到远程主机执行 Docker 命令。

工具

工具

描述

docker_ps

列出容器

docker_logs

获取日志 (tail, since, grep)

docker_exec

在容器内运行命令

docker_run

启动新容器

docker_start / docker_stop / docker_restart

生命周期控制

docker_rm

删除容器

docker_inspect

详细的容器/镜像信息

docker_stats

资源使用快照

docker_top

容器内进程

docker_images

列出镜像

docker_pull / docker_rmi / docker_build

镜像管理

docker_compose_ps/up/down/logs/restart/pull

Compose 操作

docker_system_df

磁盘使用情况

docker_info / docker_version

系统信息

docker_network_ls / docker_volume_ls

网络和卷列表

设置

1. 克隆仓库

git clone git@github.com:Isak-Landin/mcp-docker-engine.git ~/mcp-docker-engine
cd ~/mcp-docker-engine

你可以克隆到任何目录。将 ~/mcp-docker-engine 替换为你偏好的路径 — 只需在第 5 步中使用相同的路径即可。

2. 安装依赖

sudo apt install python3.12-venv
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt

3. 配置 SSH 目标

cp config.example.json config.json
# Edit config.json with your server details

config.json 字段:

{
  "host": "your-server.example.com",
  "user": "ubuntu",
  "key_path": "~/.ssh/id_rsa",
  "port": 22
}

在运行时覆盖配置路径:

DOCKER_MCP_CONFIG=/other/path/config.json .venv/bin/python3 server.py

4. 验证 SSH 访问

ssh -i ~/.ssh/id_rsa ubuntu@your-server.example.com docker ps

5. 在 GitHub Copilot 中注册

使用你克隆仓库的绝对路径。如果你使用了 ~/mcp-docker-engine,请展开它:运行 echo ~/mcp-docker-engine 获取完整路径,然后替换到下方。

MCP 服务器配置

GitHub Copilot CLI (~/.config/github-copilot/mcp.json) — 添加到你现有的 mcpServers 对象中,或者创建该文件:

"docker-mcp": {
  "command": "/your/path/to/mcp-docker-engine/.venv/bin/python3",
  "args": ["/your/path/to/mcp-docker-engine/server.py"]
}

VS Code / Copilot in VS Code (.vscode/mcp.json 或用户设置) — 添加到你现有的 servers 对象中,或者创建该文件:

"docker-mcp": {
  "type": "stdio",
  "command": "/your/path/to/mcp-docker-engine/.venv/bin/python3",
  "args": ["/your/path/to/mcp-docker-engine/server.py"]
}

Copilot 指令

instructions.md 包含了所有 26 个工具的使用示例。你可以:

  • 添加 其内容到你现有的 Copilot 指令文件中(例如 .github/copilot-instructions.md 或你的工作区指令)

  • 直接使用(如果你还没有指令文件)

注意事项

  • SSH 连接使用 StrictHostKeyChecking=accept-new - 对已知主机安全,密钥更改时会发出警告。

  • docker_builddocker_pull 使用 5-10 分钟的超时时间;如果需要,请调整 server.py 中的 timeout

  • 对于 Compose 工具,project_dir 是包含 docker-compose.yml远程路径。

  • docker_logsdocker_exec 将 stderr 重定向到 stdout,以便始终捕获输出。

A
license - permissive license
-
quality - not tested
C
maintenance

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Isak-Landin/mcp-docker-engine'

If you have feedback or need assistance with the MCP directory API, please join our Discord server