The Docker MCP server lets your AI assistant manage Docker containers, images, volumes, and networks directly from your chat window. It can list running containers, start and stop services, view logs, inspect configurations, and help debug containerized applications. Configure it to connect to your local Docker daemon, and your AI becomes a hands-on DevOps assistant that understands your container infrastructure and can take action on it.
Manage Docker Containers from Your AI Assistant
The Docker MCP server connects your AI assistant to your local Docker daemon, exposing tools to manage containers, images, volumes, and networks. Instead of memorizing Docker CLI commands, you can ask your AI to list running containers, check logs for errors, restart failed services, inspect container configurations, and manage the entire lifecycle of your Docker infrastructure. This is especially valuable for developers working with multi-container applications, Docker Compose stacks, and local development environments that rely on containerized services like databases, caches, and message queues.
Prerequisites
- Docker Desktop or Docker Engine installed and running
- Node.js 18 or later installed on your machine
- Claude Desktop, Cursor, or another MCP-compatible AI host
- Basic familiarity with Docker concepts (containers, images, volumes)
Step-by-step guide
Verify Docker is running
Verify Docker is running
Before configuring the MCP server, make sure Docker is installed and the daemon is running. Open a terminal and run 'docker ps' to verify. If you see a list of containers (or an empty list), Docker is working. If you get a connection error, start Docker Desktop or the Docker service first.
1# Verify Docker is running:2docker ps34# Expected output (even if no containers):5# CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESExpected result: Docker is installed and the daemon is running, confirmed by the docker ps command working.
Add the Docker MCP server to your configuration
Add the Docker MCP server to your configuration
Open your MCP host's configuration file and add a docker entry. The Docker MCP server connects to the Docker daemon socket on your machine. The configuration uses npx with the -y flag for automatic installation.
1{2 "mcpServers": {3 "docker": {4 "command": "npx",5 "args": [6 "-y",7 "@modelcontextprotocol/server-docker"8 ]9 }10 }11}Expected result: Your configuration file contains the Docker MCP server entry.
Restart your AI host and verify the connection
Restart your AI host and verify the connection
Fully quit and reopen Claude Desktop, Cursor, or VS Code. The Docker MCP server will connect to your local Docker daemon. Its tools for container, image, volume, and network management should appear in the available tools list.
Expected result: The Docker MCP server shows as connected with container management tools available.
List and inspect running containers
List and inspect running containers
Start with read-only operations to verify the connection. Ask the AI to list your running containers, inspect specific containers, or show resource usage. The AI translates your natural language requests into Docker API calls.
1Example prompts:23"List all running Docker containers with their ports and status"45"Show me the configuration of the postgres container"67"What Docker images are currently downloaded on my machine?"Expected result: The AI returns a list of containers, images, and their details from your Docker environment.
View logs and debug container issues
View logs and debug container issues
One of the most valuable use cases is debugging. Ask the AI to check container logs for errors, inspect environment variables, or investigate why a container is failing. The AI can read logs, parse error messages, and suggest fixes — all through natural language.
1Example prompts:23"Show me the last 50 lines of logs from the api-server container"45"Check if the redis container has any error messages in its logs"67"Why is the postgres container restarting? Show me its logs and exit code"Expected result: The AI retrieves container logs and provides analysis of errors or issues found.
Start, stop, and manage container lifecycle
Start, stop, and manage container lifecycle
The AI can start, stop, restart, and remove containers. It can also pull images, create containers from images, and manage Docker Compose stacks. Always review the action in Claude Desktop's approval dialog before confirming, especially for destructive operations like removing containers or volumes.
1Example prompts:23"Stop the old-api container and remove it"45"Restart the postgres container"67"Pull the latest nginx:alpine image and create a new container running on port 8080"Expected result: The AI performs the requested container lifecycle operations and confirms the results.
Complete working example
1{2 "mcpServers": {3 "docker": {4 "command": "npx",5 "args": [6 "-y",7 "@modelcontextprotocol/server-docker"8 ]9 }10 }11}1213// VS Code variant (.vscode/mcp.json):14// {15// "servers": {16// "docker": {17// "command": "npx",18// "args": ["-y", "@modelcontextprotocol/server-docker"]19// }20// }21// }2223// No API keys required — connects to local Docker daemon.24// Docker must be running before starting the MCP server.2526// Available tools:27// - list_containers: List running containers (optionally all)28// - inspect_container: Get detailed container configuration29// - container_logs: View container log output30// - start_container: Start a stopped container31// - stop_container: Stop a running container32// - restart_container: Restart a container33// - remove_container: Remove a stopped container34// - list_images: List downloaded Docker images35// - pull_image: Download an image from a registry36// - list_volumes: List Docker volumes37// - list_networks: List Docker networks38// - create_container: Create a new container from an imageCommon mistakes when using the Docker MCP server
Why it's a problem: Starting the MCP server before Docker is running
How to avoid: The Docker MCP server needs to connect to the Docker daemon on startup. Make sure Docker Desktop is running before you launch your AI host. If the server fails, restart your AI host after starting Docker.
Why it's a problem: Removing containers or volumes without understanding the impact
How to avoid: Always review destructive actions in the approval dialog. Removing a container does not remove its volumes by default, but removing a volume deletes all data in it permanently. Ask the AI to list what would be affected before confirming.
Why it's a problem: Running the MCP server without proper Docker socket permissions
How to avoid: On Linux, the Docker socket requires permission to access. Your user must be in the docker group or you need to run with appropriate permissions. On macOS with Docker Desktop, this is handled automatically.
Why it's a problem: Asking the AI to manage production containers from a local machine
How to avoid: The Docker MCP server connects to the local Docker daemon only. It cannot manage remote Docker hosts or cloud container services (ECS, Cloud Run, etc.) without additional configuration. Use it for local development environments.
Best practices
- Ensure Docker is running before starting your AI host
- Use specific container names rather than IDs when telling the AI what to manage
- Review all destructive operations (remove, prune) in the approval dialog before confirming
- Start with read-only operations (list, inspect, logs) before performing actions
- Combine with the filesystem MCP server so the AI can read docker-compose.yml files
- Use the AI to analyze container logs for errors rather than scrolling through them manually
- Keep your Docker environment clean — ask the AI to identify unused images and stopped containers
- Back up important volume data before letting the AI remove or modify containers
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I want to set up the Docker MCP server so my AI assistant can manage my Docker containers. Walk me through configuring it in Claude Desktop and show me how to list containers, view logs, and restart services.
List all running containers, show me the logs from the api container for the last 5 minutes, and tell me if there are any error patterns. Then restart the api container if you find issues.
Frequently asked questions
Can the Docker MCP server manage Docker Compose stacks?
The server operates at the Docker daemon level, managing individual containers, images, and volumes. It can see containers started by Docker Compose, but it does not directly parse docker-compose.yml files. Combine with the filesystem MCP server to have the AI read your Compose file and understand the full stack.
Can the AI pull and run any Docker image?
Yes, the AI can pull images from Docker Hub and other registries, then create and start containers from them. Always review the image name and configuration in the approval dialog to avoid running untrusted images.
Does it work with Docker on remote servers?
By default, the server connects to the local Docker daemon socket. Connecting to remote Docker hosts requires configuring the DOCKER_HOST environment variable, which involves security considerations like SSH tunneling or TLS certificates.
Can I use this with Podman instead of Docker?
Podman provides a Docker-compatible socket. If Podman is configured with its socket enabled, the MCP server may work with it. However, this is not officially tested and some commands may behave differently.
Will the AI accidentally delete important containers?
In Claude Desktop, all destructive operations require your explicit approval in a confirmation dialog. The AI will not remove containers, images, or volumes without your permission. Always read the confirmation carefully.
Can RapidDev help me set up a containerized development environment with MCP?
Yes. RapidDev can help design Docker-based development environments with proper multi-container orchestration, MCP server integration for AI-assisted management, and CI/CD pipelines for containerized deployments.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation