home / mcp / docker mcp server

Docker MCP Server

MCP server for Docker

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "ckreiling-mcp-server-docker": {
      "command": "uvx",
      "args": [
        "mcp-server-docker"
      ],
      "env": {
        "DOCKER_HOST": "ssh://[email protected]"
      }
    }
  }
}

You have a Docker MCP Server that lets you manage Docker engines using natural language. It lets you compose containers, introspect running services, and handle persistent data with Docker volumes, all through an intuitive command-flow driven by natural language prompts.

How to use

Connect with an MCP client and use the docker_compose prompt to plan and apply container configurations through plain language. You provide a project name and a description of the containers you want, and the system guides you from plan to apply. If you need to adjust the plan, you can give feedback and the system recalculates.

How to install

Prerequisites: You need a runtime to execute MCP servers. The server can run via PyPi with uvx or inside a Docker container.

"mcpServers": {
  "mcp-server-docker": {
    "command": "uvx",
    "args": [
      "mcp-server-docker"
    ]
  }
}

Install from PyPi with uvx if you don’t have uvx installed yet. Then add the MCP server configuration snippet shown above to your MCP servers file.

Or run the server in Docker for convenience. Build the image and start with the provided runtime configuration.

# Build the Docker image
docker build -t mcp-server-docker .

# Start the MCP server using the Docker socket for local Docker access

Then add this Docker-based MCP server configuration snippet to your MCP servers file to run the server locally with Docker access.

"mcpServers": {
  "mcp-server-docker": {
    "command": "docker",
    "args": [
      "run",
      "-i",
      "--rm",
      "-v",
      "/var/run/docker.sock:/var/run/docker.sock",
      "mcp-server-docker:latest"
    ]
  }
}

Configuration and remote access

This MCP server connects to Docker using the Python Docker SDK and supports connecting to remote engines. You can configure remote access by providing a host URL via DOCKER_HOST, including SSH-based connections.

"mcpServers": {
  "mcp-server-docker": {
    "command": "uvx",
    "args": [
      "mcp-server-docker"
    ],
    "env": {
      "DOCKER_HOST": "ssh://[email protected]"
    }
  }
}

Notes on usage and safety

Be mindful of security when running containers and never include sensitive data like API keys or passwords directly in prompts. The MCP server does not enable privileged containers or cap-add/cap-drop by default for safety.

Review any containers created by the LLM before they run on your host. Docker is not a sandbox, so monitor and manage access carefully.

Additional tips

If you need to connect to a remote Docker daemon over SSH, include the SSH-based host URL in the MCP server definition as shown in the remote example.

Available tools

list_containers

List containers with basic details such as id, name, status, and image.

create_container

Create a new container from an image with specified configurations.

run_container

Run a container from an image with command and options.

recreate_container

Recreate an existing container using updated settings.

start_container

Start a stopped container.

fetch_container_logs

Fetch and tail logs from a running or completed container.

stop_container

Stop a running container.

remove_container

Remove a container from the host.

list_images

List available Docker images.

pull_image

Pull an image from a registry.

push_image

Push an image to a registry.

build_image

Build a new image from a Dockerfile.

remove_image

Remove an image from the local daemon.

list_networks

List Docker networks.

create_network

Create a new Docker network.

remove_network

Remove a Docker network.

list_volumes

List Docker volumes.

create_volume

Create a new Docker volume.

remove_volume

Remove a Docker volume.