container_create
Create and start Docker containers with image selection, port mapping, and environment variable configuration.
Instructions
Create and start a new Docker container
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image | Yes | Docker image name | |
| name | No | Container name | |
| ports | No | Port mappings (e.g. ["80:80"]) | |
| env | No | Environment variables (e.g. ["KEY=value"]) |
Implementation Reference
- src/services/docker.service.ts:26-43 (handler)Core implementation of container creation logic: builds 'docker run' command with image, name, ports, env and executes it.async createContainer(params: { image: string; name?: string; ports?: string[]; env?: string[]; }): Promise<string> { const { image, name, ports, env } = params; let cmd = 'run -d'; if (name) cmd += ` --name ${name}`; if (ports) { ports.forEach(p => cmd += ` -p ${p}`); } if (env) { env.forEach(e => cmd += ` -e ${e}`); } cmd += ` ${image}`; return this.executeCommand(cmd); }
- src/servers/mcp.server.ts:230-247 (handler)MCP CallToolRequestSchema handler for 'container_create': parses arguments and delegates to dockerService.createContainer.case 'container_create': { const { image, name, ports, env } = request.params.arguments as { image: string; name?: string; ports?: string[]; env?: string[]; }; const output = await this.dockerService.createContainer({ image, name, ports, env, }); return { content: [{ type: 'text', text: `Container created: ${output}` }], }; }
- src/servers/mcp.server.ts:103-130 (registration)Tool registration in ListToolsRequestSchema response: defines name, description, and input schema for container_create.{ name: 'container_create', description: 'Create and start a new Docker container', inputSchema: { type: 'object', properties: { image: { type: 'string', description: 'Docker image name', }, name: { type: 'string', description: 'Container name', }, ports: { type: 'array', items: { type: 'string' }, description: 'Port mappings (e.g. ["80:80"])', }, env: { type: 'array', items: { type: 'string' }, description: 'Environment variables (e.g. ["KEY=value"])', }, }, required: ['image'], }, },
- src/servers/mcp.server.ts:106-129 (schema)Input schema definition for container_create tool, specifying properties and requirements.inputSchema: { type: 'object', properties: { image: { type: 'string', description: 'Docker image name', }, name: { type: 'string', description: 'Container name', }, ports: { type: 'array', items: { type: 'string' }, description: 'Port mappings (e.g. ["80:80"])', }, env: { type: 'array', items: { type: 'string' }, description: 'Environment variables (e.g. ["KEY=value"])', }, }, required: ['image'], },