Skip to main content
Glama

docker_list_containers

List Docker containers to view their status, images, and ports for monitoring and management. Use the 'all' parameter to include stopped containers.

Instructions

List Docker containers with their status, image, and ports

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
allNoShow all containers (default: only running)

Implementation Reference

  • The handler function implementation for listing docker containers.
    export async function listContainers(args: Record<string, unknown>): Promise<string> {
      const docker = getDockerClient();
      const all = (args.all as boolean) || false;
      const containers = await docker.listContainers({ all });
    
      if (containers.length === 0) {
        return all ? "No containers found." : "No running containers found.";
      }
    
      const headers = ["ID", "NAME", "IMAGE", "STATUS", "PORTS"];
      const rows = containers.map((c) => [
        c.Id.substring(0, 12),
        (c.Names?.[0] || "").replace(/^\//, ""),
        c.Image,
        c.Status,
        (c.Ports || []).map((p) =>
          p.PublicPort ? `${p.PublicPort}→${p.PrivatePort}/${p.Type}` : `${p.PrivatePort}/${p.Type}`
        ).join(", "),
      ]);
    
      return `Containers${all ? " (all)" : " (running)"}:\n\n${formatTable(headers, rows)}`;
    }
  • Registration of the docker_list_containers tool.
    {
      name: "docker_list_containers",
      description: "List Docker containers with their status, image, and ports",
      inputSchema: {
        type: "object" as const,
        properties: {
          all: { type: "boolean", description: "Show all containers (default: only running)" },
        },
      },
    },

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/batu-sonmez/infraclaude'

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