Docker Integration MCP Servers

Docker MCP servers provide interfaces for LLMs to interact with Docker containers and services. These servers enable AI models to manage containers, handle image operations, and assist with Docker infrastructure tasks.

GitHub starsnpm versionnpm downloads

Overview

The MCP Docker Server enables AI models to interact directly with Docker through the Model Context Protocol (MCP). It provides a standardized interface for container operations, allowing AI to assist with container management, image handling, and Docker infrastructure tasks.

Official Server:

Developed and maintained by Model Context Protocol

Key Features

🐳

Container Management

Start, stop, restart, and remove Docker containers.

📦

Image Operations

Build, pull, push, and remove Docker images.

⚙️

Service Orchestration

Manage Docker services and stacks.

💾

Volume Management

Create, inspect, and remove Docker volumes.

Tools

Quick Reference

ToolPurposeCategory
list_containersList all Docker containersContainer Management
create_containerCreate a new Docker containerContainer Management
run_containerCreate and start a Docker containerContainer Management
recreate_containerStop, remove, and run a new containerContainer Management
start_containerStart a Docker containerContainer Management
fetch_container_logsFetch logs from a Docker containerContainer Management
stop_containerStop a Docker containerContainer Management
remove_containerRemove a Docker containerContainer Management
list_imagesList Docker imagesImage Management
pull_imagePull a Docker image from a registryImage Management
push_imagePush a Docker image to a registryImage Management
build_imageBuild a Docker image from a DockerfileImage Management
remove_imageRemove a Docker imageImage Management
list_networksList Docker networksNetwork Management
create_networkCreate a Docker networkNetwork Management
remove_networkRemove a Docker networkNetwork Management
list_volumesList Docker volumesVolume Management
create_volumeCreate a Docker volumeVolume Management
remove_volumeRemove a Docker volumeVolume Management

Detailed Usage

list_containers

List all Docker containers.

use_mcp_tool({
  server_name: "docker",
  tool_name: "list_containers",
  arguments: {
    all: true,
    filters: {
      status: ["running"]
    }
  }
});

Returns a list of container objects.

create_container

Create a new Docker container without starting it.

use_mcp_tool({
  server_name: "docker",
  tool_name: "create_container",
  arguments: {
    image: "ubuntu:latest",
    name: "my-ubuntu-container",
    command: ["echo", "Hello from Docker"]
  }
});

Returns the ID of the created container.

run_container

Create and start a new Docker container (preferred over create_container + start_container).

use_mcp_tool({
  server_name: "docker",
  tool_name: "run_container",
  arguments: {
    image: "nginx:latest",
    name: "my-nginx-server",
    ports: {"80/tcp": "8080"},
    detach: true
  }
});

Returns the ID of the running container.

recreate_container

Stop and remove a container, then run a new container.

use_mcp_tool({
  server_name: "docker",
  tool_name: "recreate_container",
  arguments: {
    container_id: "my-old-container",
    image: "my-app:v2",
    name: "my-new-app"
  }
});

Returns the ID of the newly created and running container.

start_container

Start a Docker container.

use_mcp_tool({
  server_name: "docker",
  tool_name: "start_container",
  arguments: {
    container_id: "my-stopped-container"
  }
});

Returns success or error.

fetch_container_logs

Fetch logs from a Docker container.

use_mcp_tool({
  server_name: "docker",
  tool_name: "fetch_container_logs",
  arguments: {
    container_id: "my-running-container",
    tail: 100
  }
});

Returns the container logs.

stop_container

Stop a Docker container.

use_mcp_tool({
  server_name: "docker",
  tool_name: "stop_container",
  arguments: {
    container_id: "my-running-container"
  }
});

Returns success or error.

remove_container

Remove a Docker container.

use_mcp_tool({
  server_name: "docker",
  tool_name: "remove_container",
  arguments: {
    container_id: "my-old-container",
    force: true
  }
});

Returns success or error.

list_images

List Docker images.

use_mcp_tool({
  server_name: "docker",
  tool_name: "list_images",
  arguments: {
    filters: {
      dangling: false
    }
  }
});

Returns a list of image objects.

pull_image

Pull a Docker image from a registry.

use_mcp_tool({
  server_name: "docker",
  tool_name: "pull_image",
  arguments: {
    repository: "ubuntu",
    tag: "22.04"
  }
});

Returns success or error.

push_image

Push a Docker image to a registry.

use_mcp_tool({
  server_name: "docker",
  tool_name: "push_image",
  arguments: {
    repository: "myregistry/my-app",
    tag: "latest"
  }
});

Returns success or error.

build_image

Build a Docker image from a Dockerfile.

use_mcp_tool({
  server_name: "docker",
  tool_name: "build_image",
  arguments: {
    path: ".",
    dockerfile: "Dockerfile",
    tag: "my-custom-image:latest"
  }
});

Returns success or error.

remove_image

Remove a Docker image.

use_mcp_tool({
  server_name: "docker",
  tool_name: "remove_image",
  arguments: {
    image: "my-old-image:latest",
    force: true
  }
});

Returns success or error.

list_networks

List Docker networks.

use_mcp_tool({
  server_name: "docker",
  tool_name: "list_networks",
  arguments: {
    filters: {
      driver: ["bridge"]
    }
  }
});

Returns a list of network objects.

create_network

Create a Docker network.

use_mcp_tool({
  server_name: "docker",
  tool_name: "create_network",
  arguments: {
    name: "my-custom-network",
    driver: "bridge"
  }
});

Returns the ID of the created network.

remove_network

Remove a Docker network.

use_mcp_tool({
  server_name: "docker",
  tool_name: "remove_network",
  arguments: {
    network_id: "my-custom-network"
  }
});

Returns success or error.

list_volumes

List Docker volumes.

use_mcp_tool({
  server_name: "docker",
  tool_name: "list_volumes",
  arguments: {}
});

Returns a list of volume objects.

create_volume

Create a Docker volume.

use_mcp_tool({
  server_name: "docker",
  tool_name: "create_volume",
  arguments: {
    name: "my-data-volume",
    driver: "local"
  }
});

Returns the name of the created volume.

remove_volume

Remove a Docker volume.

use_mcp_tool({
  server_name: "docker",
  tool_name: "remove_volume",
  arguments: {
    volume_name: "my-data-volume",
    force: false
  }
});

Returns success or error.

Installation

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

Common Use Cases

1. Automating Container Deployments

Deploy and manage application containers programmatically:

// Deploy a new web application container
use_mcp_tool({
  server_name: "docker",
  tool_name: "run_container",
  arguments: {
    image: "my-webapp:latest",
    name: "my-webapp-instance",
    ports: {"80/tcp": "8080"},
    detach: true
  }
});

2. Managing Development Environments

Spin up and tear down isolated development environments:

// Start a development database container
use_mcp_tool({
  server_name: "docker",
  tool_name: "run_container",
  arguments: {
    image: "postgres:13",
    name: "dev-db",
    env: ["POSTGRES_DB=mydb", "POSTGRES_USER=user", "POSTGRES_PASSWORD=password"],
    ports: {"5432/tcp": "5432"},
    detach: true
  }
});

3. CI/CD Pipeline Integration

Integrate Docker operations into continuous integration and deployment workflows:

// Build and push a new Docker image as part of a CI pipeline
use_mcp_tool({
  server_name: "docker",
  tool_name: "build_image",
  arguments: {
    path: ".",
    dockerfile: "Dockerfile",
    tag: "my-app:$(BUILD_NUMBER)"
  }
});

use_mcp_tool({
  server_name: "docker",
  tool_name: "push_image",
  arguments: {
    repository: "myregistry/my-app",
    tag: "$(BUILD_NUMBER)"
  }
});

Configuration

The Docker MCP server does not require a connection string. It interacts directly with the Docker daemon available in its environment. Ensure Docker is running and accessible from where the MCP server is launched.

Sources