From d4bdb099d0d0005da811929496133a20bf4c887f Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Sun, 12 Oct 2025 16:51:02 +0800 Subject: [PATCH] Add Docker CLI support to Docker image with INSTALL_EXT build argument (#366) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: samanhappy <2755122+samanhappy@users.noreply.github.com> --- .github/DOCKER_CLI_TEST.md | 88 ++++++++++++++++++++++++++ Dockerfile | 10 +++ docs/configuration/docker-setup.mdx | 32 ++++++++++ docs/zh/configuration/docker-setup.mdx | 32 ++++++++++ 4 files changed, 162 insertions(+) create mode 100644 .github/DOCKER_CLI_TEST.md diff --git a/.github/DOCKER_CLI_TEST.md b/.github/DOCKER_CLI_TEST.md new file mode 100644 index 0000000..01179c4 --- /dev/null +++ b/.github/DOCKER_CLI_TEST.md @@ -0,0 +1,88 @@ +# Docker CLI Installation Test Procedure + +This document describes how to test the Docker CLI installation feature added with the `INSTALL_EXT=true` build argument. + +## Test 1: Build with INSTALL_EXT=false (default) + +```bash +# Build without extended features +docker build -t mcphub:base . + +# Run the container +docker run --rm mcphub:base docker --version +``` + +**Expected Result**: `docker: not found` error (Docker CLI is NOT installed) + +## Test 2: Build with INSTALL_EXT=true + +```bash +# Build with extended features +docker build --build-arg INSTALL_EXT=true -t mcphub:extended . + +# Test Docker CLI is available +docker run --rm mcphub:extended docker --version +``` + +**Expected Result**: Docker version output (e.g., `Docker version 27.x.x, build xxxxx`) + +## Test 3: Docker-in-Docker Workflow + +```bash +# Build with extended features +docker build --build-arg INSTALL_EXT=true -t mcphub:extended . + +# Run with Docker socket mounted +docker run -d \ + --name mcphub-test \ + -p 3000:3000 \ + -v /var/run/docker.sock:/var/run/docker.sock \ + mcphub:extended + +# Test Docker commands from inside the container +docker exec mcphub-test docker ps +docker exec mcphub-test docker images + +# Cleanup +docker stop mcphub-test +docker rm mcphub-test +``` + +**Expected Result**: Docker commands should work and show the host's containers and images + +## Test 4: Verify Image Size + +```bash +# Build both versions +docker build -t mcphub:base . +docker build --build-arg INSTALL_EXT=true -t mcphub:extended . + +# Compare image sizes +docker images mcphub:* +``` + +**Expected Result**: +- The `extended` image should be larger than the `base` image +- The size difference should be reasonable (Docker CLI adds ~60-80MB) + +## Test 5: Architecture Support + +```bash +# On AMD64/x86_64 +docker build --build-arg INSTALL_EXT=true --platform linux/amd64 -t mcphub:extended-amd64 . + +# On ARM64 +docker build --build-arg INSTALL_EXT=true --platform linux/arm64 -t mcphub:extended-arm64 . +``` + +**Expected Result**: +- Both builds should succeed +- AMD64 includes Chrome/Playwright + Docker CLI +- ARM64 includes Docker CLI only (Chrome installation is skipped) + +## Notes + +- The Docker CLI installation follows the official Docker documentation +- The installation uses the Debian Bookworm repository +- All temporary files are cleaned up to minimize image size +- The feature is opt-in via the `INSTALL_EXT` build argument diff --git a/Dockerfile b/Dockerfile index 4286304..b898406 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,6 +22,16 @@ RUN if [ "$INSTALL_EXT" = "true" ]; then \ else \ echo "Skipping Chrome installation on non-amd64 architecture: $ARCH"; \ fi; \ + # Install Docker CLI \ + apt-get update && \ + apt-get install -y ca-certificates curl && \ + install -m 0755 -d /etc/apt/keyrings && \ + curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc && \ + chmod a+r /etc/apt/keyrings/docker.asc && \ + echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian bookworm stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null && \ + apt-get update && \ + apt-get install -y docker-ce-cli && \ + apt-get clean && rm -rf /var/lib/apt/lists/*; \ fi RUN uv tool install mcp-server-fetch diff --git a/docs/configuration/docker-setup.mdx b/docs/configuration/docker-setup.mdx index f4c51e6..c33605f 100644 --- a/docs/configuration/docker-setup.mdx +++ b/docs/configuration/docker-setup.mdx @@ -41,6 +41,38 @@ docker run -d \ mcphub:local ``` +### Building with Extended Features + +The Docker image supports an `INSTALL_EXT` build argument to include additional tools: + +```bash +# Build with extended features (includes Docker CLI, Chrome/Playwright) +docker build --build-arg INSTALL_EXT=true -t mcphub:extended . + +# Run the container with Docker socket mounted (for Docker-in-Docker workflows) +docker run -d \ + --name mcphub \ + -p 3000:3000 \ + -v $(pwd)/mcp_settings.json:/app/mcp_settings.json \ + -v /var/run/docker.sock:/var/run/docker.sock \ + mcphub:extended + +# Verify Docker CLI is available +docker exec mcphub docker --version +``` + + + **What's included with INSTALL_EXT=true:** + - **Docker CLI**: For container management and Docker-based workflows + - **Chrome/Playwright** (amd64 only): For browser automation tasks + + The extended image is larger but provides additional capabilities for advanced use cases. + + + + When mounting the Docker socket (`/var/run/docker.sock`), the container gains access to the host's Docker daemon. Only use this in trusted environments. + + ## Docker Compose Setup ### Basic Configuration diff --git a/docs/zh/configuration/docker-setup.mdx b/docs/zh/configuration/docker-setup.mdx index 250e66b..584be04 100644 --- a/docs/zh/configuration/docker-setup.mdx +++ b/docs/zh/configuration/docker-setup.mdx @@ -41,6 +41,38 @@ docker run -d \ mcphub:local ``` +### 构建扩展功能版本 + +Docker 镜像支持 `INSTALL_EXT` 构建参数以包含额外工具: + +```bash +# 构建扩展功能版本(包含 Docker CLI、Chrome/Playwright) +docker build --build-arg INSTALL_EXT=true -t mcphub:extended . + +# 运行容器并挂载 Docker socket(用于 Docker-in-Docker 工作流) +docker run -d \ + --name mcphub \ + -p 3000:3000 \ + -v $(pwd)/mcp_settings.json:/app/mcp_settings.json \ + -v /var/run/docker.sock:/var/run/docker.sock \ + mcphub:extended + +# 验证 Docker CLI 可用 +docker exec mcphub docker --version +``` + + + **INSTALL_EXT=true 包含的功能:** + - **Docker CLI**:用于容器管理和基于 Docker 的工作流 + - **Chrome/Playwright**(仅 amd64):用于浏览器自动化任务 + + 扩展镜像较大,但为高级用例提供了额外功能。 + + + + 挂载 Docker socket(`/var/run/docker.sock`)时,容器将获得访问主机 Docker 守护进程的权限。仅在可信环境中使用此功能。 + + ## Docker Compose 设置 ### 基本配置