The Docker execution feature allows the IPFS Accelerate MCP server to execute arbitrary code in Docker containers, including running containers from Docker Hub, building and executing from GitHub repositories, and running custom payloads.
- Docker installed and running
- Python 3.8+
- IPFS Accelerate installed
docker --version
docker psfrom ipfs_accelerate_py.mcp.tools.docker_tools import execute_docker_container
result = execute_docker_container(
image="python:3.9",
command="python -c 'print(\"Hello from Docker!\")'",
memory_limit="512m",
timeout=60
)
print(f"Output: {result['stdout']}")from ipfs_accelerate_py.mcp.tools.docker_tools import build_and_execute_github_repo
result = build_and_execute_github_repo(
repo_url="https://github.com/user/python-app",
branch="main",
command="python app.py",
environment={"ENV": "production"}
)
print(f"Success: {result['success']}")from ipfs_accelerate_py.mcp.tools.docker_tools import execute_with_payload
script = """
print("Processing data...")
result = 2 + 2
print(f"Result: {result}")
"""
result = execute_with_payload(
image="python:3.9",
payload=script,
payload_path="/app/script.py",
entrypoint="python /app/script.py"
)
print(f"Output: {result['stdout']}")ipfs_accelerate_py.docker_executor (core module)
↓
ipfs_accelerate_py.mcp.tools.docker_tools (MCP wrappers)
↓
MCP Server
↓
JavaScript SDK
- execute_docker_container - Run containers from Docker Hub
- build_and_execute_github_repo - Build and run from GitHub
- execute_with_payload - Execute custom code
- list_running_containers - List active containers
- stop_container - Stop containers
- pull_docker_image - Pull images
// Execute Docker container
const result = await mcp.call_tool("execute_docker_container", {
image: "python:3.9",
command: "python -c 'print(2+2)'",
memory_limit: "512m",
timeout: 60
});
console.log("Output:", result.stdout);✅ Network isolation by default
✅ Resource limits (CPU, memory)
✅ No new privileges
✅ Read-only filesystem option
✅ Timeout protection
✅ Automatic cleanup
# Core Docker executor tests
python -m unittest test.test_docker_executor
# MCP Docker tools tests
python -m unittest ipfs_accelerate_py.mcp.tests.test_docker_tools
# All Docker tests
python -m unittest test.test_docker_executor ipfs_accelerate_py.mcp.tests.test_docker_tools- Total Tests: 32
- Pass Rate: 100%
- Coverage: 30% increase
See examples/docker_execution_examples.py for 10 comprehensive examples including:
- Python script execution
- Shell commands
- Data processing
- Multi-language support
- Resource limits
- Error handling
- User Guide:
docs/DOCKER_EXECUTION.md(12KB) - Implementation:
docs/DOCKER_IMPLEMENTATION_SUMMARY.md(11KB) - Examples:
examples/docker_execution_examples.py(340 lines)
# Install Docker
# Ubuntu/Debian
sudo apt-get install docker.io
# Add user to docker group
sudo usermod -aG docker $USER# Add user to docker group
sudo usermod -aG docker $USER
# Log out and back infrom ipfs_accelerate_py.mcp.tools.docker_tools import pull_docker_image
# Pull image first
pull_docker_image(image="python:3.9")execute_docker_container(
image="python:3.9-slim",
command="python -c 'import sys; print(sys.version)'",
memory_limit="256m"
)execute_with_payload(
image="python:3.9",
payload="import json; data = {'result': 42}; print(json.dumps(data))",
payload_path="/app/process.py",
entrypoint="python /app/process.py"
)# Python
execute_docker_container(image="python:3.9", command="python --version")
# Node.js
execute_docker_container(image="node:16", command="node --version")
# Ruby
execute_docker_container(image="ruby:3.0", command="ruby --version")- Container startup: < 1s (for cached images)
- Execution overhead: Minimal
- Resource limits: Enforced
- Cleanup: Automatic
- Requires Docker installed
- Network isolation by default (configurable)
- Resource limits enforced
- Timeout protection active
- Docker Compose support
- GPU support for ML workloads
- Container caching
- Streaming logs
- Kubernetes backend
- Issues: https://github.com/endomorphosis/ipfs_accelerate_py/issues
- Documentation: See
docs/directory - Examples: See
examples/directory
GNU Affero General Public License v3 or later (AGPLv3+)
Status: Production Ready ✅
Tests: 32/32 Passing ✅
Documentation: Complete ✅
Integration: Verified ✅