docker_start
Start one or more stopped Docker containers by name or ID to resume their operation in your development environment.
Instructions
Start one or more stopped containers
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| containers | Yes | Container name(s) or ID(s) | |
| cwd | No | Working directory |
Implementation Reference
- src/tools/docker.ts:244-247 (handler)Main handler function that constructs and executes the 'docker start' command on specified containers using the executeDockerCommand helper.export async function dockerStart(args: z.infer<typeof dockerStartSchema>): Promise<ToolResponse> { const containers = Array.isArray(args.containers) ? args.containers.join(' ') : args.containers; return executeDockerCommand(`docker start ${containers}`, args.cwd); }
- src/tools/docker.ts:114-117 (schema)Zod schema for input validation of docker_start tool parameters (containers and optional cwd).export const dockerStartSchema = z.object({ containers: z.union([z.string(), z.array(z.string())]).describe('Container name(s) or ID(s)'), cwd: z.string().optional().describe('Working directory') });
- src/tools/docker.ts:410-427 (registration)MCP tool definition/registration in dockerTools array, including name, description, and JSON inputSchema for the docker_start tool.{ name: 'docker_start', description: 'Start one or more stopped containers', inputSchema: { type: 'object', properties: { containers: { oneOf: [ { type: 'string' }, { type: 'array', items: { type: 'string' } } ], description: 'Container name(s) or ID(s)' }, cwd: { type: 'string', description: 'Working directory' } }, required: ['containers'] } },
- src/index.ts:455-457 (handler)Top-level dispatch handler in MCP server that matches tool name 'docker_start', validates arguments, and invokes the dockerStart function.if (name === 'docker_start') { const validated = dockerStartSchema.parse(args); return await dockerStart(validated);
- src/tools/docker.ts:21-62 (helper)Core helper utility that executes any Docker command via child_process.execAsync, handles output/error formatting, and returns standardized 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 }; } }