🔌

Docker MCP

DevTools720

Manage Docker containers, images, networks, and volumes from AI agents.

Claude DesktopCursorWindsurf

Overview

Manage Docker containers, images, networks, and volumes from AI agents.

Setup

Run with npx:

npx -y @modelcontextprotocol/server-docker

Configuration

Docker socket access required

Documentation

Docker MCP

Overview

Docker MCP provides direct access to Docker, enabling AI agents to manage containers, images, networks, and volumes. Perfect for container debugging, development workflows, and managing Docker-based infrastructure.

Features

  • Container Management: Run, stop, start, restart, and remove containers
  • Image Operations: Pull, build, list, and remove Docker images
  • Log Access: View container logs in real-time
  • Exec Commands: Run commands inside running containers
  • Network Management: List and manage Docker networks
  • Volume Management: List, create, and remove volumes
  • System Info: Get Docker system information and events

Installation

npx -y @modelcontextprotocol/server-docker

Configuration

Add to your Claude Desktop config:

{
  "mcpServers": {
    "docker": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-docker"]
    }
  }
}

Permission Requirements

The MCP server needs access to the Docker socket. On Linux, this typically requires adding your user to the docker group:

sudo usermod -aG docker $USER
newgrp docker

On macOS (with Docker Desktop), the socket is available by default.

Available Tools

ToolDescription
list_containersList running containers
create_containerCreate a new container
start_containerStart a stopped container
stop_containerStop a running container
remove_containerRemove a container
exec_containerRun a command in a container
logs_containerGet container logs
list_imagesList Docker images
pull_imagePull a Docker image
build_imageBuild an image from Dockerfile
remove_imageRemove a Docker image
list_networksList Docker networks
list_volumesList Docker volumes
system_infoGet Docker system information

Usage Examples

Container Management

List all running containers

Stop container "my-app-1"

Start container "my-app-1"

Remove container "old-container"

Run Commands in Containers

Execute "ls -la" in container "my-app-1"

Execute "npm test" in container "my-app-1"

View Logs

Get last 100 lines of logs from container "my-app-1"

Follow logs from container "my-app-1" (real-time)

Image Operations

List all Docker images

Pull image "nginx:latest"

Build image from Dockerfile in current directory

Run a New Container

Run container from image "python:3.11" with command "python app.py"

Run container "redis" with port mapping 6379:6379

Claude Desktop Setup

  1. Ensure Docker is running
  2. Install the MCP server
  3. Add configuration to claude_desktop_config.json
  4. Restart Claude Desktop
  5. The Docker tool will appear in your available tools

Security Considerations

  • Docker socket access gives root-equivalent privileges
  • Only enable Docker MCP on trusted development machines
  • Consider using read-only access for inspection-only workflows
  • Be cautious when executing commands in containers

Pros

  • ✅ Full Docker CLI functionality
  • ✅ Great for container debugging
  • ✅ Can run and manage containers directly
  • ✅ Real-time log access
  • ✅ No additional dependencies

Cons

  • ❌ Requires Docker to be installed and running
  • ❌ Docker socket access is powerful (security consideration)
  • ❌ No built-in Docker Compose support
  • ❌ Container operations can affect local development

Resources