MCP ConfigsApr 8, 2026·3 min read

Docker MCP — Container Management for AI Agents

MCP server that gives AI agents Docker container management capabilities. Build, run, stop, and inspect containers through tool calls for automated DevOps workflows.

TL;DR
Docker MCP lets AI agents build, run, stop, and inspect Docker containers through the Model Context Protocol.
§01

What it is

Docker MCP is a Model Context Protocol server that gives AI agents direct access to Docker container operations. Through MCP tool calls, an agent can list running containers, start and stop services, inspect container logs, build images, and manage Docker networks and volumes.

This server is for developers who want their AI coding assistant to manage Docker environments without switching to a terminal. It is useful for debugging containerized applications, spinning up development databases, and automating container lifecycle tasks.

§02

How it saves time or tokens

Instead of copying Docker commands between your terminal and AI chat, the agent executes Docker operations directly. It can inspect a failing container's logs, identify the issue, and suggest fixes in one conversation turn. The workflow provides the MCP configuration JSON for immediate setup.

§03

How to use

  1. Add the Docker MCP server to your .mcp.json:
{
  "mcpServers": {
    "docker": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-docker"]
    }
  }
}
  1. Restart your MCP-compatible client (Claude Code, Cursor, etc.).
  1. Ask the agent to manage containers:
'List all running containers'
'Show logs from the postgres container'
'Build and run the Dockerfile in this directory'
'Stop all containers and clean up unused images'
§04

Example

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

With this config, the agent can run operations like:

# Agent executes these via MCP tool calls:
docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
docker logs --tail 50 my-api-server
docker build -t my-app:latest .
docker run -d --name my-app -p 3000:3000 my-app:latest
§05

Related on TokRepo

§06

Common pitfalls

  • The Docker daemon must be running on your machine. The MCP server connects to the local Docker socket and fails silently if Docker Desktop or dockerd is not started.
  • Giving the agent Docker access means it can stop or remove containers. Be cautious in environments with production containers running alongside development ones.
  • Building large images through the MCP server may time out with default settings. For complex builds, run them directly in the terminal.

Frequently Asked Questions

What Docker operations can the agent perform?+

The agent can list, start, stop, and remove containers. It can also build images, view logs, inspect container details, manage networks and volumes, and execute commands inside running containers.

Does this require Docker Desktop?+

You need a running Docker daemon. Docker Desktop provides this on macOS and Windows. On Linux, the Docker Engine (dockerd) is sufficient. The MCP server communicates through the standard Docker socket.

Is it safe to give AI agents Docker access?+

Use caution. The agent has the same Docker permissions as your user. It can stop containers, remove images, and create new ones. Avoid using it in environments where production containers share the same Docker daemon.

Can the agent work with Docker Compose?+

The MCP server exposes Docker Engine API operations. For Compose-specific commands (docker compose up/down), the agent would need to execute shell commands. Basic container operations work directly through MCP tools.

Does this work on remote Docker hosts?+

By default it connects to the local Docker socket. To connect to a remote host, you would need to configure the DOCKER_HOST environment variable in the MCP server configuration.

Citations (3)
🙏

Source & Thanks

Part of the Model Context Protocol Servers collection.

Docker MCP — Container management for AI agents

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.