Skip to main content
Glama

remove_container

Remove Docker containers from your system. Specify container ID or name, and use force=true to stop and delete running containers.

Instructions

Remove a Docker container. Use force=true to remove running containers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesContainer ID or name
forceNoForce remove running container

Implementation Reference

  • The handler function that executes the remove_container tool logic. It gets a Docker container by ID and calls the Docker API's remove method with the force option.
    export async function removeContainer(
      id: string,
      force: boolean,
    ): Promise<string> {
      const container = docker.getContainer(id);
      await container.remove({ force });
      return `Container ${id} removed`;
    }
  • src/index.ts:100-115 (registration)
    Registration of the remove_container tool with the MCP server. Defines the tool name, description, input schema using Zod, and the handler that calls removeContainer.
    server.tool(
      "remove_container",
      "Remove a Docker container. Use force=true to remove running containers.",
      {
        id: z.string().describe("Container ID or name"),
        force: z
          .boolean()
          .optional()
          .default(false)
          .describe("Force remove running container"),
      },
      async ({ id, force }) => {
        const result = await removeContainer(id, force);
        return { content: [{ type: "text", text: result }] };
      },
    );
  • Zod schema definition for remove_container tool inputs: 'id' (required string for container ID/name) and 'force' (optional boolean, defaults to false, for force-removing running containers).
    {
      id: z.string().describe("Container ID or name"),
      force: z
        .boolean()
        .optional()
        .default(false)
        .describe("Force remove running container"),
    },

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