Skip to main content
Glama

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
NameRequiredDescriptionDefault
idYesImage ID or tag
forceNoForce remove

Implementation Reference

  • 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 }] };
      },
    );
  • 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"),
    },
  • Import statement that brings the removeImage function from ./docker.js into the main server module for use in tool registration.
    removeImage,

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/ofershap/mcp-server-docker'

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