Skip to main content
Glama

remove_container

Delete a Docker container using its ID or name, optionally forcing removal of running containers. Simplifies container management in the Docker MCP Server environment.

Instructions

Remove a Docker container

Input Schema

NameRequiredDescriptionDefault
containerYesContainer ID or name
forceNoForce removal of running container

Input Schema (JSON Schema)

{ "properties": { "container": { "description": "Container ID or name", "type": "string" }, "force": { "description": "Force removal of running container", "type": "boolean" } }, "required": [ "container" ], "type": "object" }

Implementation Reference

  • The handler function that implements the 'remove_container' tool. It checks for the required 'container' argument, optionally adds force flag, executes 'docker rm' command, and returns the stdout as text content.
    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:151-168 (registration)
    Registration of the 'remove_container' tool in the ListTools response. Includes name, description, and inputSchema defining 'container' (required string) and optional 'force' boolean.
    { 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'], }, },
  • TypeScript interface ContainerActionArgs defining the input parameters for remove_container: container (string, required), force (boolean, optional). Used for type checking in the handler.
    interface ContainerActionArgs { container: string; force?: boolean; }
  • src/index.ts:197-198 (registration)
    Dispatch case in CallToolRequest handler that routes 'remove_container' calls to the removeContainer method.
    case 'remove_container': return await this.removeContainer(request.params.arguments as unknown as ContainerActionArgs);

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/suvarchal/docker-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server