MCP ExplorerExplorer

Mcp Docker

@C0rWinon 9 months ago
1 MIT
FreeCommunity
AI Systems
MCP Docker integrates Docker operations with the Model Control Protocol for seamless API interactions.

Overview

What is Mcp Docker

MCP Docker is a powerful integration tool that enables Docker operations through the Model Control Protocol (MCP) platform. It acts as a bridge between Docker commands and API services, facilitating seamless interaction with Docker containers and images via a standardized API interface.

Use cases

Use cases for MCP Docker include automating container management tasks, integrating Docker operations into CI/CD pipelines, generating reports on container usage, and managing multi-platform Docker images.

How to use

To use MCP Docker, you need to have Go 1.24.2 or higher and Docker installed. You can build it from source by cloning the repository and using the provided Makefile commands to build binaries or Docker images. You can also pull images from registries and manage Docker containers using various commands like ps, exec, and run.

Key features

Key features of MCP Docker include listing and managing Docker containers, executing commands within containers, inspecting changes to container filesystems, managing Docker images, pulling images from registries, and generating Software Bill of Materials (SBOM).

Where to use

MCP Docker can be used in various fields such as software development, DevOps, and cloud computing, where containerization and Docker management are essential for application deployment and orchestration.

Content

MCP Docker Integration Tool

Overview

MCP Docker is a powerful integration tool that provides Docker operations through the Model Control Protocol (MCP) platform. It serves as a bridge between Docker commands and API services, allowing seamless interaction with Docker containers and images through a standardized API interface.

Available Operations

  • ps - List and manage Docker containers
  • exec - Execute commands in containers
  • diff - Inspect changes to container filesystems
  • history - Show image history
  • image - Manage Docker images
  • inspect - Get detailed information about Docker objects
  • pull - Pull images from registries
  • run - Create and start containers
  • sbom - Generate Software Bill of Materials
  • search - Search Docker images

Prerequisites

  • Go 1.24.2 or higher
  • Docker installed and running
  • golangci-lint (for development)

Installation

Build from Source

# Clone the repository
git clone https://github.com/mark3labs/mcp-docker
cd mcp-docker

# Build for current platform
make build

# Build for all supported platforms
make build-all

Docker Image

# Build Docker image
make docker

# Build and push to registry
REGISTRY=your-registry make docker-push

Makefile Commands

Command Description Example
make build Build binary for current platform make build
make build-all Build for multiple platforms (linux/amd64, linux/arm64, darwin/amd64, darwin/arm64) make build-all
make docker Build Docker image make docker
make docker-push Push Docker image to registry REGISTRY=your-registry make docker-push
make test Run tests make test
make test-coverage Run tests with coverage make test-coverage
make lint Run linter make lint
make clean Remove build artifacts make clean
make clean-docker Remove Docker images make clean-docker
make clean-all Remove all artifacts and Docker images make clean-all

Customizable Variables

  • VERSION (default: 0.1.0)
  • REGISTRY (default: empty)
  • GOOS (default: linux)
  • GOARCH (default: amd64)

Usage

Starting the Service

# Run directly
./mcp-docker serve

# Run via Docker
docker run -d \
  --name mcp-docker \
  --privileged \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -e DOCKER_TLS_CERTDIR= \
  -p 8080:8080 \
  mcp-docker:latest

Development

Project Structure

.
├── api/          # API definitions
├── cmd/          # Command line interface
├── internal/     # Internal packages
│   └── docker/   # Docker operations implementation
├── pkg/          # Public packages
├── Dockerfile    # Container image definition
├── Makefile     # Build and development commands
└── main.go      # Application entry point

Testing

# Run all tests
make test

# Run tests with coverage
make test-coverage

Linting

# Run linter
make lint

Docker Configuration

Environment Variables

  • DOCKER_TLS_CERTDIR: TLS certificate directory
  • DOCKER_API_VERSION: Docker API version (default: 1.48)
  • TZ: Timezone (default: UTC)

Volume Mounts

  • /var/run/docker.sock:/var/run/docker.sock - Docker daemon socket

Network Configuration

The container requires access to:

  • Host network (when using host networking mode)
  • Docker daemon socket
  • Exposed port 8080 for API access

Claude.AI Integration

{
  "docker": {
    "command": "docker",
    "args": [
      "run",
      "--rm",
      "-i",
      "--name",
      "mcp-docker",
      "--privileged",
      "-v",
      "/var/run/docker.sock:/var/run/docker.sock",
      "-e",
      "DOCKER_TLS_CERTDIR=",
      "-e",
      "DOCKER_API_VERSION=1.48",
      "--network",
      "host",
      "mcp-docker:latest"
    ]
  }
}

Dependencies

Main Dependencies

Indirect Dependencies

License

This project is licensed under the MIT License - see the LICENSE file for details.

The MIT License is a permissive license that is short and to the point. It lets people do anything they want with your code as long as they provide attribution back to you and don’t hold you liable.

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Security

This tool requires privileged access to the Docker daemon. Ensure proper security measures are in place when deploying in production environments.

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers