docker_images
Perform Docker image operations including list, pull, push, remove, tag, inspect, prune, and history. Filter by dangling images or force remove images.
Instructions
Manage Docker images (list, pull, push, remove, etc.)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Action to perform on images | |
| image | No | Image name or ID | |
| tag | No | Tag for image operations | |
| force | No | Force removal or operation | |
| all | No | Apply to all images (for list/prune) | |
| filter | No | Filter results (e.g., "dangling=true") |
Implementation Reference
- src/services/DockerService.ts:603-685 (handler)Handler for docker_images tool - manages Docker images via CLI commands (list, pull, push, remove, tag, inspect, prune, history, save, load, import)
async manageImages(args: DockerImageArgs): Promise<ToolResult> { const { action, image, tag, repository, file, filter, all, force, no_prune, dangling, until } = args; ValidationUtils.validateRequired({ action }, ['action']); let command = 'docker image'; switch (action) { case 'list': command = 'docker images'; if (all) command += ' -a'; if (filter) command += ` --filter ${filter}`; if (dangling) command += ' --filter dangling=true'; break; case 'remove': if (!image) throw new Error('Image name/ID is required for remove action'); command = `docker rmi ${image}`; if (force) command += ' -f'; if (no_prune) command += ' --no-prune'; break; case 'pull': if (!image) throw new Error('Image name is required for pull action'); command = `docker pull ${image}`; break; case 'push': if (!image) throw new Error('Image name is required for push action'); command = `docker push ${image}`; break; case 'tag': if (!image || !tag) throw new Error('Both source image and target tag are required'); command = `docker tag ${image} ${tag}`; break; case 'inspect': if (!image) throw new Error('Image name/ID is required for inspect action'); command = `docker image inspect ${image}`; break; case 'prune': command = 'docker image prune'; if (all) command += ' -a'; if (force) command += ' -f'; if (filter) command += ` --filter ${filter}`; if (until) command += ` --filter until=${until}`; break; case 'history': if (!image) throw new Error('Image name/ID is required for history action'); command = `docker history ${image}`; break; case 'save': if (!image || !file) throw new Error('Image name and output file are required for save action'); command = `docker save -o ${file} ${image}`; break; case 'load': if (!file) throw new Error('Input file is required for load action'); command = `docker load -i ${file}`; break; case 'import': if (!file) throw new Error('Input file is required for import action'); command = `docker import ${file}`; if (repository) command += ` ${repository}`; if (tag) command += `:${tag}`; break; default: throw new Error(`Unsupported image action: ${action}`); } try { const execTimeout = ['pull', 'push', 'save', 'load'].includes(action) ? this.pullTimeout : this.defaultTimeout; return await this.executeDockerCommand(command, { cwd: this.getCurrentWorkspace() }, execTimeout); } catch (error: any) { throw new Error(`Docker image ${action} failed: ${error.message}`); } } - src/services/DockerService.ts:89-101 (schema)TypeScript interface defining the input schema for docker_images tool arguments
export interface DockerImageArgs { action: 'list' | 'remove' | 'pull' | 'push' | 'tag' | 'inspect' | 'build' | 'prune' | 'history' | 'save' | 'load' | 'import'; image?: string; tag?: string; repository?: string; file?: string; filter?: string; all?: boolean; force?: boolean; no_prune?: boolean; dangling?: boolean; until?: string; } - src/index.ts:211-212 (registration)Registration of docker_images tool case handler dispatching to DockerService.manageImages()
case 'docker_images': return await this.dockerService.manageImages(args as DockerImageArgs); - src/toolDefinitions.ts:489-508 (schema)Tool definition/input schema registration for docker_images tool
{ name: 'docker_images', description: 'Manage Docker images (list, pull, push, remove, etc.)', inputSchema: { type: 'object', properties: { action: { type: 'string', enum: ['list', 'pull', 'push', 'remove', 'tag', 'inspect', 'prune', 'history'], description: 'Action to perform on images' }, image: { type: 'string', description: 'Image name or ID' }, tag: { type: 'string', description: 'Tag for image operations' }, force: { type: 'boolean', description: 'Force removal or operation' }, all: { type: 'boolean', description: 'Apply to all images (for list/prune)' }, filter: { type: 'string', description: 'Filter results (e.g., "dangling=true")' }, }, required: ['action'], }, },