Dev ToolsΒ·
advanced
Β·12 min readΒ·Apr 4, 2026

How to Use the Docker MCP Server for Container Management

Manage Docker containers, images, and volumes through your AI agent using the Docker MCP server. Build, run, and monitor containers with natural language.

DockercontainersDevOpsinfrastructuredeployment
Interactive Tool
1-Click Export

Generate & Test Docker MCP Server Config

One-click export with environment variables & path locators for Claude Desktop, Cursor, Windsurf, and OpenAI Codex CLI.

Open in Generator

Use the Docker MCP Server for Container Management

The Docker MCP server connects your AI agent directly to the Docker daemon. This allows your agent to manage your local infrastructure, spin up ephemeral test environments, monitor resource usage, and build new container images entirely through natural language commands.

Prerequisites

  • β–ΈDocker Desktop or the Docker Engine installed.
  • β–ΈThe Docker daemon running in the background.
  • β–ΈNode.js 18+ installed on your host machine.

Configuration Setup

Add this configuration to your MCP client:

json
{
  "mcpServers": {
    "docker": {
      "command": "npx",
      "args": ["-y", "mcp-server-docker"]
    }
  }
}

Available Tools

The agent is granted an extensive set of tools categorized by function:

Container Operations

  • β–Έlist_containers β€” List running and stopped containers.
  • β–Έcreate_container β€” Create new containers from images.
  • β–Έstart_container / stop_container β€” Manage container lifecycle.
  • β–Έremove_container β€” Delete containers.
  • β–Έcontainer_logs β€” View container stdout and stderr logs.
  • β–Έcontainer_stats β€” Get live resource usage statistics (CPU, Memory).

Image Operations

  • β–Έlist_images β€” List available local images.
  • β–Έpull_image β€” Pull new images from Docker Hub or private registries.
  • β–Έbuild_image β€” Build images dynamically from Dockerfiles.
  • β–Έremove_image β€” Delete unused images.

Volume & Network Operations

  • β–Έlist_volumes / create_volume β€” Manage persistent storage.
  • β–Έlist_networks β€” List Docker bridge networks.

Example Workflows

  • β–ΈContainer Monitoring: "Show me all running containers and their current CPU usage. If any are over 80%, fetch their last 50 lines of logs."
  • β–ΈQuick Deployment: "Pull the latest nginx image and run it on port 8080 with the name 'web-server'."
  • β–ΈCleanup: "List all stopped containers and remove them, then prune any dangling unused images to free up disk space."

Security Considerations & Troubleshooting

  • β–ΈRoot Access Warning: Giving an AI agent full access to the Docker socket is effectively giving it root access to your host machine. The agent can mount your host filesystem (/) into a privileged container. Never run this in a production environment without strict RBAC or socket filtering.
  • β–ΈCannot connect to the Docker daemon: The MCP server is failing to locate the docker.sock. Ensure Docker Desktop is actually running. If you are on Linux, you may need to add the user running the MCP server to the docker group.
  • β–ΈPull Limits: If the agent attempts to pull images repeatedly, you may hit Docker Hub's anonymous rate limits. Configure your host Docker engine with authentication to bypass this.

Using with OpenAI Codex

To use this MCP server with the OpenAI Codex CLI, you can add it to your configuration using the codex mcp add command:

bash
codex mcp add --name docker --command "npx @modelcontextprotocol/server-docker"

(Note: Depending on the server, you may need to append arguments or use --env flags for environment variables as described in the configuration section above)

Ready to Deploy?

Build your full agent toolstack in the Visual Generator

Combine Docker with databases, search APIs, and memory graphs in a single configuration file.

Customize in Generator

Related Guides