feat: Auto-start Docker daemon when installed in container (#370)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: samanhappy <2755122+samanhappy@users.noreply.github.com>
Co-authored-by: samanhappy <samanhappy@gmail.com>
This commit is contained in:
Copilot
2025-10-13 22:38:13 +08:00
committed by GitHub
parent 16a92096b3
commit 3e9e5cc3c9
5 changed files with 115 additions and 26 deletions

View File

@@ -1,6 +1,6 @@
# Docker CLI Installation Test Procedure
# Docker Engine Installation Test Procedure
This document describes how to test the Docker CLI installation feature added with the `INSTALL_EXT=true` build argument.
This document describes how to test the Docker Engine installation feature added with the `INSTALL_EXT=true` build argument.
## Test 1: Build with INSTALL_EXT=false (default)
@@ -12,7 +12,7 @@ docker build -t mcphub:base .
docker run --rm mcphub:base docker --version
```
**Expected Result**: `docker: not found` error (Docker CLI is NOT installed)
**Expected Result**: `docker: not found` error (Docker is NOT installed)
## Test 2: Build with INSTALL_EXT=true
@@ -26,13 +26,44 @@ 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
## Test 3: Docker-in-Docker with Auto-start Daemon
```bash
# Build with extended features
docker build --build-arg INSTALL_EXT=true -t mcphub:extended .
# Run with Docker socket mounted
# Run with privileged mode (allows Docker daemon to start)
docker run -d \
--name mcphub-test \
--privileged \
-p 3000:3000 \
mcphub:extended
# Wait a few seconds for daemon to start
sleep 5
# Test Docker commands from inside the container
docker exec mcphub-test docker ps
docker exec mcphub-test docker images
docker exec mcphub-test docker info
# Cleanup
docker stop mcphub-test
docker rm mcphub-test
```
**Expected Result**:
- Docker daemon should auto-start inside the container
- Docker commands should work without mounting the host's Docker socket
- `docker info` should show the container's own Docker daemon
## Test 4: Docker-in-Docker with Host Socket (Alternative)
```bash
# Build with extended features
docker build --build-arg INSTALL_EXT=true -t mcphub:extended .
# Run with Docker socket mounted (uses host's daemon)
docker run -d \
--name mcphub-test \
-p 3000:3000 \
@@ -48,9 +79,11 @@ docker stop mcphub-test
docker rm mcphub-test
```
**Expected Result**: Docker commands should work and show the host's containers and images
**Expected Result**:
- Docker daemon should NOT auto-start (socket already exists from host)
- Docker commands should work and show the host's containers and images
## Test 4: Verify Image Size
## Test 5: Verify Image Size
```bash
# Build both versions
@@ -63,9 +96,9 @@ 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)
- The size difference should be reasonable (Docker Engine adds ~100-150MB)
## Test 5: Architecture Support
## Test 6: Architecture Support
```bash
# On AMD64/x86_64
@@ -77,12 +110,15 @@ docker build --build-arg INSTALL_EXT=true --platform linux/arm64 -t mcphub:exten
**Expected Result**:
- Both builds should succeed
- AMD64 includes Chrome/Playwright + Docker CLI
- ARM64 includes Docker CLI only (Chrome installation is skipped)
- AMD64 includes Chrome/Playwright + Docker Engine
- ARM64 includes Docker Engine only (Chrome installation is skipped)
## Notes
- The Docker CLI installation follows the official Docker documentation
- The Docker Engine installation follows the official Docker documentation
- Includes full Docker daemon (`dockerd`), CLI (`docker`), and containerd
- The daemon auto-starts when running in privileged mode
- 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
- `iptables` is installed as it's required for Docker networking