Back to Blog
How to Use Docker MCP with Claude Code
Manage Docker containers, images, volumes, and networks from Claude Code — build, run, inspect, and debug your containerized applications without leaving your editor.
dockercontainersdevopsinfrastructureclaude-code
What is the Docker MCP?
The Docker MCP connects Claude Code to the Docker Engine API on your local machine or a remote Docker host. Claude can build images, start and stop containers, inspect logs, manage volumes and networks, and help you debug containerization issues — all with full context of your codebase.
Installation
mcpizy install docker
The MCP connects to the Docker socket at /var/run/docker.sock by default. For remote hosts, provide the Docker host URL and TLS certificates during setup.
Key Capabilities
- Build images — trigger
docker buildand stream output back to Claude for analysis. - Run and manage containers — start, stop, restart, and remove containers with environment variables and port mappings.
- Stream container logs — fetch stdout/stderr from any running or stopped container.
- Inspect containers and images — view configuration, environment variables, and layer details.
- Manage volumes and networks — create, inspect, and clean up Docker resources.
Example Usage
Your containerized API is failing to start. Ask Claude to diagnose it:
// Claude will:
// 1. List running and exited containers
// 2. Fetch logs from the failed container
// 3. Inspect the container's environment and entrypoint
// 4. Suggest fixes to your Dockerfile or docker-compose.yml
Tips and Best Practices
- Use multi-stage builds — ask Claude to audit your Dockerfile for unnecessary layers that bloat image size.
- Combine with Kubernetes MCP once you move from local Docker to a cluster.
- Use the log streaming capability to tail logs from multiple containers simultaneously during debugging.
- Be cautious granting write access to the Docker socket in shared environments — it is equivalent to root access.
Found this useful? Share it.