remove_image
Delete Docker images to free up disk space and manage container resources. Use force option to remove images that are in use.
Instructions
Remove a Docker image. Use force=true to force removal.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Image ID or tag | |
| force | No | Force remove |
Implementation Reference
- src/docker.ts:191-195 (handler)The handler function that executes the remove_image tool logic. Uses Dockerode to get the image by ID and calls its remove() method with the force option, returning a success message.
export async function removeImage(id: string, force: boolean): Promise<string> { const image = docker.getImage(id); await image.remove({ force }); return `Image ${id} removed`; } - src/index.ts:175-186 (registration)Registration of the 'remove_image' MCP tool using server.tool(). Defines the tool name, description, Zod schema for input validation (id: string, force: boolean with default false), and the async handler that calls removeImage().
server.tool( "remove_image", "Remove a Docker image. Use force=true to force removal.", { id: z.string().describe("Image ID or tag"), force: z.boolean().optional().default(false).describe("Force remove"), }, async ({ id, force }) => { const result = await removeImage(id, force); return { content: [{ type: "text", text: result }] }; }, ); - src/index.ts:178-181 (schema)Zod schema definition for remove_image tool inputs: 'id' (required string for image ID or tag) and 'force' (optional boolean defaulting to false for forced removal).
{ id: z.string().describe("Image ID or tag"), force: z.boolean().optional().default(false).describe("Force remove"), }, - src/index.ts:14-14 (helper)Import statement that brings the removeImage function from ./docker.js into the main server module for use in tool registration.
removeImage,