Docker Hub MCP 伺服器
Docker Hub MCP 伺服器是一個模型上下文協定 (MCP) 伺服器,它與 Docker Hub API 介接,使大型語言模型 (LLM) 能夠存取豐富的映像檔後設資料,進而實現智慧內容探索與儲存庫管理。開發者在使用容器(特別是在 AI 和由 LLM 驅動的工作流程中)時,往往面臨 Docker Hub 龐大生態中上下文不足的問題。結果導致 LLM 很難推薦正確的映像檔,而開發者則浪費時間在手動搜尋而非進行建構上。
主要功能
- 進階 LLM 上下文:Docker 的 MCP 伺服器為 LLM 提供了 Docker Hub 映像檔的詳細結構化上下文,無論開發者是在選擇基礎映像檔還是自動化 CI/CD 工作流程,都能獲得更聰明、更相關的推薦。
- 自然語言映像檔探索:開發者可以使用自然語言找到正確的容器映像檔,無需記住標籤或儲存庫名稱。只需描述您的需求,Docker Hub 就會回傳符合您意圖的映像檔。
- 簡化儲存庫管理:Hub MCP 伺服器使代理程式能夠透過自然語言管理儲存庫,包括獲取映像檔詳細資訊、查看統計資料、搜尋內容以及快速輕鬆地執行關鍵操作。
安裝 Docker Hub MCP 伺服器
從 **MCP 工具包 (MCP Toolkit)** 選單中,選擇 **目錄 (Catalog)** 分頁,搜尋 **Docker Hub**,並選擇加號圖示以新增 Docker Hub MCP 伺服器。
在伺服器的 **組態 (Configuration)** 分頁中,輸入您的 Docker Hub 使用者名稱和個人存取權杖 (PAT)。
在 MCP 工具包的 **客戶端 (Clients)** 分頁中,確保 Gordon 已連線。
現在,您可以從 **詢問 Gordon (Ask Gordon)** 選單發送與您的 Docker Hub 帳戶相關的請求,並遵循 Docker Hub MCP 伺服器提供的工具說明。若要進行測試,請詢問 Gordon
What repositories are in my namespace?
提示預設情況下,Gordon 客戶端 是啟用的,這意味著 Gordon 可以自動與您的 MCP 伺服器進行互動。
使用 Claude Desktop 作為客戶端
將 Docker Hub MCP 伺服器組態新增至您的
claude_desktop_config.json{ "mcpServers": { "docker-hub": { "command": "node", "args": ["/FULL/PATH/TO/YOUR/docker-hub-mcp-server/dist/index.js", "--transport=stdio"] } } }其中
/FULL/PATH/TO/YOUR/docker-hub-mcp-server是您複製該儲存庫的完整路徑
{ "mcpServers": { "docker-hub": { "command": "node", "args": ["/FULL/PATH/TO/YOUR/docker-hub-mcp-server/dist/index.js", "--transport=stdio", "--username=YOUR_DOCKER_HUB_USERNAME"], "env": { "HUB_PAT_TOKEN": "YOUR_DOCKER_HUB_PERSONAL_ACCESS_TOKEN" } } } }其中
YOUR_DOCKER_HUB_USERNAME是您的 Docker Hub 使用者名稱。YOUR_DOCKER_HUB_PERSONAL_ACCESS_TOKEN是 Docker Hub 個人存取權杖/FULL/PATH/TO/YOUR/docker-hub-mcp-server是您複製該儲存庫的完整路徑
儲存組態檔案並徹底重新啟動 Claude Desktop,以使變更生效。
在 Visual Studio Code 中使用
將 Docker Hub MCP 伺服器組態新增至 Visual Studio Code 中的使用者設定 (JSON) 檔案。您可以透過開啟
命令面板 (Command Palette)並輸入Preferences: Open User Settings (JSON)來執行此操作。{ "mcpServers": { "docker-hub": { "command": "node", "args": ["/FULL/PATH/TO/YOUR/docker-hub-mcp-server/dist/index.js", "--transport=stdio"] } } }其中
/FULL/PATH/TO/YOUR/docker-hub-mcp-server是您複製該儲存庫的完整路徑
{ "mcpServers": { "docker-hub": { "command": "node", "args": ["/FULL/PATH/TO/YOUR/docker-hub-mcp-server/dist/index.js", "--transport=stdio"], "env": { "HUB_USERNAME": "YOUR_DOCKER_HUB_USERNAME", "HUB_PAT_TOKEN": "YOUR_DOCKER_HUB_PERSONAL_ACCESS_TOKEN" } } } }其中
YOUR_DOCKER_HUB_USERNAME是您的 Docker Hub 使用者名稱。YOUR_DOCKER_HUB_PERSONAL_ACCESS_TOKEN是 Docker Hub 個人存取權杖/FULL/PATH/TO/YOUR/docker-hub-mcp-server是您複製該儲存庫的完整路徑
開啟
命令面板 (Command Palette)並輸入MCP: List Servers。選擇
docker-hub並選擇Start Server。
使用其他客戶端
若要將 Docker Hub MCP 伺服器整合到您自己的開發環境中,請參閱 hub-mcp GitHub 儲存庫 上的原始程式碼和安裝說明。
使用範例
本節提供了使用 Docker Hub 工具進行常見操作的任務導向範例。
尋找映像檔
# Search for official images
$ docker ai "Search for official nginx images on Docker Hub"
# Search for lightweight images to reduce deployment size and improve performance
$ docker ai "Search for minimal Node.js images with small footprint"
# Get the most recent tag of a base image
$ docker ai "Show me the latest tag details for go"
# Find a production-ready database with enterprise features and reliability
$ docker ai "Search for production ready database images"
# Compare Ubuntu versions to choose the right one for my project
$ docker ai "Help me find the right Ubuntu version for my project"
儲存庫管理
# Create a repository
$ docker ai "Create a repository in my namespace"
# List all repositories in my namespace
$ docker ai "List all repositories in my namespace"
# Find the largest repository in my namespace
$ docker ai "Which of my repositories takes up the most space?"
# Find repositories that haven't been updated recently
$ docker ai "Which of my repositories haven't had any pushes in the last 60 days?"
# Find which repositories are currently active and being used
$ docker ai "Show me my most recently updated repositories"
# Get details about a repository
$ docker ai "Show me information about my '<repository-name>' repository"
提取/推送映像檔
# Pull latest PostgreSQL version
$ docker ai "Pull the latest postgres image"
# Push image to your Docker Hub repository
$ docker ai "Push my <image-name> to my <repository-name> repository"
標籤管理
# List all tags for a repository
$ $ docker ai "Show me all tags for my '<repository-name>' repository"
# Find the most recently pushed tag
$ docker ai "What's the most recent tag pushed to my '<repository-name>' repository?"
# List tags with architecture filtering
$ docker ai "List tags for in the '<repository-name>' repository that support amd64 architecture"
# Get detailed information about a specific tag
$ docker ai "Show me details about the '<tag-name>' tag in the '<repository-name>' repository"
# Check if a specific tag exists
$ docker ai "Check if version 'v1.2.0' exists for my 'my-web-app' repository"
Docker 強固映像檔 (Docker Hardened Images)
# List available hardened images
$ docker ai "What is the most secure image I can use to run a node.js application?"
# Convert Dockerfile to use a hardened image
$ docker ai "Can you help me update my Dockerfile to use a docker hardened image instead of the current one"
注意若要存取 Docker 強固映像檔 (Docker Hardened Images),需要訂閱。如果您有興趣使用 Docker 強固映像檔,請造訪 Docker 強固映像檔。
參考
本節提供了您可以在 Docker Hub MCP 伺服器中找到的工具清單。
Docker Hub MCP 伺服器工具
用於與您的 Docker 儲存庫互動並在 Docker Hub 上探索內容的工具。
| 名稱 | 描述 |
|---|---|
check-repository | 檢查儲存庫 |
check-repository-tag | 檢查儲存庫標籤 |
check-repository-tags | 檢查儲存庫標籤 |
create-repository | 建立新儲存庫 |
docker-hardened-images | 列出指定命名空間中可用的 Docker 強固映像檔 |
get-namespaces | 獲取使用者的組織/命名空間 |
get-repository-dockerfile | 獲取儲存庫的 Dockerfile |
get-repository-info | 獲取儲存庫資訊 |
list-repositories-by-namespace | 列出命名空間下的儲存庫 |
list-repository-tags | 列出儲存庫標籤 |
read-repository-tag | 讀取儲存庫標籤 |
search | 搜尋 Docker Hub 上的內容 |
set-repository-dockerfile | 設定儲存庫的 Dockerfile |
update-repository-info | 更新儲存庫資訊 |