docker_volumes
List, create, remove, inspect, or prune Docker volumes. Use volume name, driver, filter, or force flags to manage container storage effectively.
Instructions
Manage Docker volumes
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Action to perform on volumes | |
| volume | No | Volume name | |
| driver | No | Volume driver | |
| force | No | Force operation | |
| filter | No | Filter results |
Implementation Reference
- Interface DockerVolumeArgs defining input schema for the docker_volumes tool: action (enum: list/create/remove/inspect/prune), volume, driver, label, opt, force, filter, all.
export interface DockerVolumeArgs { action: 'list' | 'create' | 'remove' | 'inspect' | 'prune'; volume?: string; driver?: string; label?: Record<string, string>; opt?: Record<string, string>; force?: boolean; filter?: string; all?: boolean; } - src/services/DockerService.ts:972-1030 (handler)manageVolumes method - the handler that executes docker_volumes tool logic. Builds docker volume CLI commands based on action (list, create, remove, inspect, prune) and runs them via executeDockerCommand.
async manageVolumes(args: DockerVolumeArgs): Promise<ToolResult> { const { action, volume, driver, label, opt, force, filter, all } = args; ValidationUtils.validateRequired({ action }, ['action']); let command = 'docker volume'; switch (action) { case 'list': command = 'docker volume ls'; if (filter) command += ` --filter ${filter}`; break; case 'create': if (!volume) throw new Error('Volume name is required for create action'); command = `docker volume create ${volume}`; if (driver) command += ` --driver ${driver}`; if (label) { for (const [key, value] of Object.entries(label)) { command += ` --label ${key}=${value}`; } } if (opt) { for (const [key, value] of Object.entries(opt)) { command += ` --opt ${key}=${value}`; } } break; case 'remove': if (!volume) throw new Error('Volume name is required for remove action'); command = `docker volume rm ${volume}`; if (force) command += ' -f'; break; case 'inspect': if (!volume) throw new Error('Volume name is required for inspect action'); command = `docker volume inspect ${volume}`; break; case 'prune': command = 'docker volume prune'; if (force) command += ' -f'; if (filter) command += ` --filter ${filter}`; if (all) command += ' -a'; break; default: throw new Error(`Unsupported volume action: ${action}`); } try { return await this.executeDockerCommand(command, { cwd: this.getCurrentWorkspace() }); } catch (error: any) { throw new Error(`Docker volume ${action} failed: ${error.message}`); } } - src/toolDefinitions.ts:551-569 (registration)Tool definition registration for 'docker_volumes' with name, description, and inputSchema specifying action enum and optional properties (volume, driver, force, filter).
{ name: 'docker_volumes', description: 'Manage Docker volumes', inputSchema: { type: 'object', properties: { action: { type: 'string', enum: ['list', 'create', 'remove', 'inspect', 'prune'], description: 'Action to perform on volumes' }, volume: { type: 'string', description: 'Volume name' }, driver: { type: 'string', description: 'Volume driver' }, force: { type: 'boolean', description: 'Force operation' }, filter: { type: 'string', description: 'Filter results' }, }, required: ['action'], }, }, - src/index.ts:217-218 (registration)Routing registration - case 'docker_volumes' dispatches to dockerService.manageVolumes.
case 'docker_volumes': return await this.dockerService.manageVolumes(args as DockerVolumeArgs);