remove_container
Delete a Docker container by ID or name. Use the force option to remove running containers.
Instructions
Remove a Docker container
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"container": "<container>"
},
"name": "remove_container"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| container | Yes | Container ID or name | |
| force | No | Force removal of running container |
Implementation Reference
- src/index.ts:332-351 (handler)The main handler function for the 'remove_container' tool. It validates the container argument, constructs the 'docker rm' command with optional force flag, executes it, and returns the stdout.
private async removeContainer(args: ContainerActionArgs) { if (!args.container) { throw new McpError( ErrorCode.InvalidParams, 'Container parameter is required' ); } const force = args.force === true ? ' -f' : ''; const { stdout } = await execAsync(`docker rm${force} ${args.container}`); return { content: [ { type: 'text', text: stdout.trim(), }, ], }; } - src/index.ts:31-34 (schema)TypeScript interface defining the input parameters for remove_container and similar container actions.
interface ContainerActionArgs { container: string; force?: boolean; } - src/index.ts:151-168 (registration)Tool registration in the ListTools response, including name, description, and input schema.
{ name: 'remove_container', description: 'Remove a Docker container', inputSchema: { type: 'object', properties: { container: { type: 'string', description: 'Container ID or name', }, force: { type: 'boolean', description: 'Force removal of running container', }, }, required: ['container'], }, }, - src/index.ts:197-198 (handler)Switch case in the CallToolRequest handler that dispatches to the removeContainer method.
case 'remove_container': return await this.removeContainer(request.params.arguments as unknown as ContainerActionArgs);