Skip to main content
Glama

docker_networks

Performs Docker network actions: list, create, remove, inspect, connect, or disconnect containers to networks.

Instructions

Manage Docker networks

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesAction to perform on networks
networkNoNetwork name or ID
containerNoContainer to connect/disconnect
driverNoNetwork driver (bridge, overlay, host, etc.)
subnetNoSubnet for network (e.g., 172.20.0.0/16)
gatewayNoGateway for network

Implementation Reference

  • The manageNetworks method handles all network operations (list, create, remove, inspect, connect, disconnect, prune) by building and executing docker network CLI commands.
    async manageNetworks(args: DockerNetworkArgs): Promise<ToolResult> {
      const { 
        action, 
        network, 
        container, 
        driver, 
        gateway, 
        subnet, 
        ip_range, 
        aux_address, 
        opt, 
        label, 
        internal, 
        attachable, 
        ingress, 
        ipv6, 
        alias = [], 
        ip, 
        ip6, 
        link = [], 
        link_local_ip = [], 
        force, 
        filter 
      } = args;
    
      ValidationUtils.validateRequired({ action }, ['action']);
    
      let command = 'docker network';
    
      switch (action) {
        case 'list':
          command = 'docker network ls';
          if (filter) command += ` --filter ${filter}`;
          break;
          
        case 'create':
          if (!network) throw new Error('Network name is required for create action');
          command = `docker network create ${network}`;
          if (driver) command += ` --driver ${driver}`;
          if (gateway) command += ` --gateway ${gateway}`;
          if (subnet) command += ` --subnet ${subnet}`;
          if (ip_range) command += ` --ip-range ${ip_range}`;
          if (internal) command += ' --internal';
          if (attachable) command += ' --attachable';
          if (ingress) command += ' --ingress';
          if (ipv6) command += ' --ipv6';
          
          if (aux_address) {
            for (const [key, value] of Object.entries(aux_address)) {
              command += ` --aux-address ${key}=${value}`;
            }
          }
          
          if (opt) {
            for (const [key, value] of Object.entries(opt)) {
              command += ` --opt ${key}=${value}`;
            }
          }
          
          if (label) {
            for (const [key, value] of Object.entries(label)) {
              command += ` --label ${key}=${value}`;
            }
          }
          break;
          
        case 'remove':
          if (!network) throw new Error('Network name/ID is required for remove action');
          command = `docker network rm ${network}`;
          break;
          
        case 'inspect':
          if (!network) throw new Error('Network name/ID is required for inspect action');
          command = `docker network inspect ${network}`;
          break;
          
        case 'connect':
          if (!network || !container) throw new Error('Network and container are required for connect action');
          command = `docker network connect`;
          alias.forEach(a => command += ` --alias ${a}`);
          if (ip) command += ` --ip ${ip}`;
          if (ip6) command += ` --ip6 ${ip6}`;
          link.forEach(l => command += ` --link ${l}`);
          link_local_ip.forEach(lip => command += ` --link-local-ip ${lip}`);
          command += ` ${network} ${container}`;
          break;
          
        case 'disconnect':
          if (!network || !container) throw new Error('Network and container are required for disconnect action');
          command = `docker network disconnect`;
          if (force) command += ' -f';
          command += ` ${network} ${container}`;
          break;
          
        case 'prune':
          command = 'docker network prune';
          if (force) command += ' -f';
          if (filter) command += ` --filter ${filter}`;
          break;
          
        default:
          throw new Error(`Unsupported network action: ${action}`);
      }
    
      try {
        return await this.executeDockerCommand(command, { cwd: this.getCurrentWorkspace() });
      } catch (error: any) {
        throw new Error(`Docker network ${action} failed: ${error.message}`);
      }
    }
  • DockerNetworkArgs interface defines the input schema for network operations with action, network, container, driver, gateway, subnet, ip_range, aux_address, opt, label, internal, attachable, ingress, ipv6, alias, ip, ip6, link, link_local_ip, force, filter properties.
    export interface DockerNetworkArgs {
      action: 'list' | 'create' | 'remove' | 'inspect' | 'connect' | 'disconnect' | 'prune';
      network?: string;
      container?: string;
      driver?: string;
      gateway?: string;
      subnet?: string;
      ip_range?: string;
      aux_address?: Record<string, string>;
      opt?: Record<string, string>;
      label?: Record<string, string>;
      internal?: boolean;
      attachable?: boolean;
      ingress?: boolean;
      ipv6?: boolean;
      alias?: string[];
      ip?: string;
      ip6?: string;
      link?: string[];
      link_local_ip?: string[];
      force?: boolean;
      filter?: string;
    }
  • src/index.ts:215-216 (registration)
    Dispatches the 'docker_networks' tool name to manageNetworks method on the DockerService.
    case 'docker_networks':
      return await this.dockerService.manageNetworks(args as DockerNetworkArgs);
  • TOOL_DEFINITIONS entry for 'docker_networks' with description and inputSchema (action, network, container, driver, subnet, gateway). Note: the schema in toolDefinitions is a subset of DockerNetworkArgs.
    {
      name: 'docker_networks',
      description: 'Manage Docker networks',
      inputSchema: {
        type: 'object',
        properties: {
          action: { 
            type: 'string', 
            enum: ['list', 'create', 'remove', 'inspect', 'connect', 'disconnect'],
            description: 'Action to perform on networks' 
          },
          network: { type: 'string', description: 'Network name or ID' },
          container: { type: 'string', description: 'Container to connect/disconnect' },
          driver: { type: 'string', description: 'Network driver (bridge, overlay, host, etc.)' },
          subnet: { type: 'string', description: 'Subnet for network (e.g., 172.20.0.0/16)' },
          gateway: { type: 'string', description: 'Gateway for network' },
        },
        required: ['action'],
      },
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description bears full responsibility for behavioral transparency. It fails to disclose any side effects (e.g., destruction, mutation, permissions) or action-specific behavior, such as whether create or remove operations are destructive or require special privileges.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very short (3 words), but for a tool with 6 parameters and multiple actions, it is underspecified. Conciseness should not sacrifice necessary information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, so the description should explain return values or behavior. It does not address any action outcomes, error conditions, or response format, leaving gaps for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema coverage is 100%, so parameters are fully described there. The description adds no extra meaning beyond the schema, earning the baseline score of 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool manages Docker networks but uses the vague verb 'manage', which does not specify the particular operations (list, create, remove, etc.) that are defined in the input schema. It does not distinguish from sibling tools like docker_containers or docker_compose, which also manage Docker resources.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description does not mention context, prerequisites, or when not to use it, leaving the agent without clear decision criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/agentics-ai/code-mcp'

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