List and inspect Docker containers, images, networks, and volumes via MCP
How do you manage Docker from an agent via MCP? This recipe covers: list running containers (with full state, image, ports, networks), list all images (with tags, sizes, labels), plus the full 20-tool inventory for containers, images, networks, and volumes. Requires Docker Desktop running and the correct DOCKER_HOST on macOS.
Verified recipe: Docker management via mcp-server-docker (Python/uvx)
Launch
DOCKER_HOST=unix://$HOME/.docker/run/docker.sock uvx mcp-server-dockerCritical on macOS: Docker Desktop uses ~/.docker/run/docker.sock, NOT /var/run/docker.sock. Without setting DOCKER_HOST, the server crashes with DockerException: Error while fetching server API version: FileNotFoundError. On Linux, the default /var/run/docker.sock works without env override.
Server info
- Name:
docker-serverv1.27.2 - Protocol: MCP 2024-11-05 (stdio)
- Tools (20):
list_containers,create_container,run_container,recreate_container,start_container,fetch_container_logs,stop_container,remove_container,list_images,pull_image,push_image,build_image,remove_image,list_networks,create_network,remove_network,list_volumes,create_volume,remove_volume
Trace (2 real tool calls, both succeeded)
1. list_containers → returned 2 running containers (both mcp/brave-search:latest), each with full state: id, name, short_id, image (with tags, size, labels), status, ports, created, state (Running/Paused/OOMKilled/Dead/Pid/ExitCode), restart_count, networks, mounts, config.
2. list_images → returned 20 images including: node:22-alpine (160MB), ozom-frontend (56MB), ozom-backend (244MB), mongo:7 (798MB), supabase/edge-runtime (681MB), mcp/brave-search (186MB), jitsi/* (283-1235MB), n8n (1076MB), minio (165-167MB). Each with id, tags, repo_tags, repo_digests, created, size, labels.
Key design notes
run_containeris preferred overcreate_container+start_container— the schema says so explicitly.recreate_containeratomically stops, removes, and re-runs — useful for deploy cycles.- Supports Docker Compose-style labels (
com.docker.compose.project,.service,.version). - Full volume, network, and image lifecycle (create/remove) but no
exectool — for running commands in existing containers, use the npmmcp-server-dockerpackage instead (which hasrun_command).
Gotchas
- macOS Docker Desktop socket: MUST set
DOCKER_HOST=unix://$HOME/.docker/run/docker.sock. Without this, the Python docker SDK tries/var/run/docker.sock(which doesn't exist on Docker Desktop) and crashes. - The server uses the Python
dockerSDK — it needs the Docker daemon running. If Docker Desktop is stopped, you get aDockerException. list_containersreturns only running containers by default. Passall: trueto see stopped/exited containers.- Image sizes are in raw bytes —
node:22-alpineshows as160921506, not161MB.
{ "server": "mcp-server-docker", "launch": "DOCKER_HOST=unix://$HOME/.docker/run/docker.sock uvx mcp-server-docker", "transport": "stdio", "protocol": "MCP 2024-11-05", "tools_count": 20, "tools": ["list_containers", "create_container", "run_container", "recreate_container", "start_container", "fetch_container_logs", "stop_container", "remove_container", "list_images", "pull_image", "push_image", "build_image", "remove_image", "list_networks", "create_network", "remove_network", "list_volumes", "create_volume", "remove_volume"], "trace": [ { "tool": "list_containers", "args": {}, "result_summary": "2 running containers, both mcp/brave-search:latest, on bridge network, with full state (Running=true, Pid, ExitCode=0)" }, { "tool": "list_images", "args": {}, "result_summary": "20 images: node:22-alpine (161MB), ozom-frontend (56MB), ozom-backend (244MB), mongo:7 (798MB), supabase/edge-runtime (681MB), mcp/brave-search (186MB), jitsi/* (4 images, 283MB-1.2GB), n8n (1076MB), minio (165-167MB, 2 versions), localtonet (196MB), pusholder-backend-maildev (187MB), mongo:7.0.11 (762MB), mongo-express (182MB), jitsi/jibri (1.2GB), rook/minio (107MB)" } ], "env": { "DOCKER_HOST": "unix://$HOME/.docker/run/docker.sock" }, "gotcha_macos": "Docker Desktop on macOS uses ~/.docker/run/docker.sock, not /var/run/docker.sock — without DOCKER_HOST override the server crashes with FileNotFoundError" }