docker_inspect
Retrieve detailed configuration and state information for Docker containers, images, networks, and volumes to debug and analyze containerized applications.
Instructions
Return low-level information on Docker objects (containers, images, networks, volumes)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | Yes | Container, image, network, or volume name/ID | |
| type | No | Type of object to inspect | |
| cwd | No | Working directory |
Implementation Reference
- src/tools/docker.ts:261-264 (handler)Main handler function for 'docker_inspect' tool. Executes 'docker inspect' command with optional type flag using the shared executeDockerCommand helper.export async function dockerInspect(args: z.infer<typeof dockerInspectSchema>): Promise<ToolResponse> { const typeFlag = args.type ? `--type ${args.type}` : ''; return executeDockerCommand(`docker inspect ${typeFlag} ${args.target}`.trim(), args.cwd); }
- src/tools/docker.ts:131-135 (schema)Zod schema used for input validation in the dispatch handler.export const dockerInspectSchema = z.object({ target: z.string().describe('Container, image, network, or volume name/ID'), type: z.enum(['container', 'image', 'network', 'volume']).optional().describe('Type of object to inspect'), cwd: z.string().optional().describe('Working directory') });
- src/index.ts:467-470 (registration)Dispatch logic in main server handler that routes 'docker_inspect' calls to the dockerInspect function after schema validation.if (name === 'docker_inspect') { const validated = dockerInspectSchema.parse(args); return await dockerInspect(validated); }
- src/tools/docker.ts:466-478 (registration)MCP tool registration definition included in dockerTools array for listTools endpoint.{ name: 'docker_inspect', description: 'Return low-level information on Docker objects (containers, images, networks, volumes)', inputSchema: { type: 'object', properties: { target: { type: 'string', description: 'Container, image, network, or volume name/ID' }, type: { type: 'string', enum: ['container', 'image', 'network', 'volume'], description: 'Type of object to inspect' }, cwd: { type: 'string', description: 'Working directory' } }, required: ['target'] } },
- src/tools/docker.ts:21-62 (helper)Shared helper function that executes docker commands via child_process.exec and formats ToolResponse.async function executeDockerCommand(command: string, cwd?: string): Promise<ToolResponse> { try { const { stdout, stderr } = await execAsync(command, { cwd: cwd || process.cwd(), shell: '/bin/bash', maxBuffer: 10 * 1024 * 1024, // 10MB buffer for logs timeout: 60000 // 60 second timeout for builds }); return { content: [ { type: "text" as const, text: JSON.stringify({ success: true, command: command, stdout: stdout.trim(), stderr: stderr.trim(), cwd: cwd || process.cwd() }, null, 2) } ] }; } catch (error: any) { return { content: [ { type: "text" as const, text: JSON.stringify({ success: false, command: command, stdout: error.stdout?.trim() || '', stderr: error.stderr?.trim() || error.message, exitCode: error.code || 1, cwd: cwd || process.cwd() }, null, 2) } ], isError: true }; } }