ruby_llm-docker 0.2.5 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/examples/docker_chat.rb +41 -0
- data/lib/ruby_llm/docker/build_image.rb +64 -65
- data/lib/ruby_llm/docker/copy_to_container.rb +89 -134
- data/lib/ruby_llm/docker/create_container.rb +64 -86
- data/lib/ruby_llm/docker/create_network.rb +63 -79
- data/lib/ruby_llm/docker/create_volume.rb +57 -79
- data/lib/ruby_llm/docker/exec_container.rb +94 -111
- data/lib/ruby_llm/docker/fetch_container_logs.rb +63 -85
- data/lib/ruby_llm/docker/list_containers.rb +46 -40
- data/lib/ruby_llm/docker/list_images.rb +34 -55
- data/lib/ruby_llm/docker/list_networks.rb +35 -57
- data/lib/ruby_llm/docker/list_volumes.rb +35 -64
- data/lib/ruby_llm/docker/pull_image.rb +24 -48
- data/lib/ruby_llm/docker/push_image.rb +60 -89
- data/lib/ruby_llm/docker/recreate_container.rb +47 -79
- data/lib/ruby_llm/docker/remove_container.rb +48 -76
- data/lib/ruby_llm/docker/remove_image.rb +53 -95
- data/lib/ruby_llm/docker/remove_network.rb +42 -78
- data/lib/ruby_llm/docker/remove_volume.rb +52 -85
- data/lib/ruby_llm/docker/run_container.rb +73 -53
- data/lib/ruby_llm/docker/start_container.rb +35 -58
- data/lib/ruby_llm/docker/stop_container.rb +40 -66
- data/lib/ruby_llm/docker/tag_image.rb +67 -95
- data/lib/ruby_llm/docker/version.rb +10 -1
- data/lib/ruby_llm/docker.rb +13 -0
- metadata +15 -1
|
@@ -2,49 +2,52 @@
|
|
|
2
2
|
|
|
3
3
|
module RubyLLM
|
|
4
4
|
module Docker
|
|
5
|
-
#
|
|
5
|
+
# MCP tool for creating Docker containers.
|
|
6
6
|
#
|
|
7
|
-
# This tool
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
7
|
+
# This tool creates a new Docker container from a specified image without
|
|
8
|
+
# starting it. The container is created in a "created" state and can be
|
|
9
|
+
# started later using the start_container tool. This two-step process
|
|
10
|
+
# allows for container configuration before execution.
|
|
11
11
|
#
|
|
12
12
|
# == Features
|
|
13
13
|
#
|
|
14
|
-
# -
|
|
15
|
-
# -
|
|
16
|
-
# -
|
|
17
|
-
# -
|
|
18
|
-
# -
|
|
19
|
-
# -
|
|
20
|
-
# - Comprehensive error handling with specific error types
|
|
14
|
+
# - Creates containers from any available Docker image
|
|
15
|
+
# - Supports custom container naming
|
|
16
|
+
# - Configures command execution and environment variables
|
|
17
|
+
# - Sets up port exposure and network configuration
|
|
18
|
+
# - Applies advanced host configurations
|
|
19
|
+
# - Handles container labeling and metadata
|
|
21
20
|
#
|
|
22
21
|
# == Security Considerations
|
|
23
22
|
#
|
|
24
|
-
#
|
|
25
|
-
# -
|
|
26
|
-
# -
|
|
27
|
-
# -
|
|
28
|
-
# -
|
|
23
|
+
# Container creation is a powerful operation that can:
|
|
24
|
+
# - **Resource Allocation**: Consume system resources and storage
|
|
25
|
+
# - **Network Access**: Create network endpoints and bindings
|
|
26
|
+
# - **File System Access**: Mount host directories and volumes
|
|
27
|
+
# - **Security Context**: Run with elevated privileges if configured
|
|
29
28
|
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
# -
|
|
35
|
-
# -
|
|
29
|
+
# Implement proper access controls and resource limits.
|
|
30
|
+
#
|
|
31
|
+
# == Parameters
|
|
32
|
+
#
|
|
33
|
+
# - **image**: Docker image to use (required)
|
|
34
|
+
# - **name**: Custom container name (optional)
|
|
35
|
+
# - **cmd**: Command to execute as space-separated string (optional)
|
|
36
|
+
# - **env**: Environment variables as comma-separated KEY=VALUE pairs (optional)
|
|
37
|
+
# - **exposed_ports**: Port exposure configuration as JSON object (optional)
|
|
38
|
+
# - **host_config**: Advanced host configuration as JSON object (optional)
|
|
36
39
|
#
|
|
37
40
|
# == Example Usage
|
|
38
41
|
#
|
|
39
42
|
# # Simple container creation
|
|
40
|
-
# CreateContainer.call(
|
|
43
|
+
# response = CreateContainer.call(
|
|
41
44
|
# server_context: context,
|
|
42
45
|
# image: "nginx:latest",
|
|
43
46
|
# name: "web-server"
|
|
44
47
|
# )
|
|
45
48
|
#
|
|
46
49
|
# # Advanced container with configuration
|
|
47
|
-
# CreateContainer.call(
|
|
50
|
+
# response = CreateContainer.call(
|
|
48
51
|
# server_context: context,
|
|
49
52
|
# image: "postgres:13",
|
|
50
53
|
# name: "database",
|
|
@@ -56,76 +59,49 @@ module RubyLLM
|
|
|
56
59
|
# }
|
|
57
60
|
# )
|
|
58
61
|
#
|
|
59
|
-
# @see
|
|
60
|
-
# @see StartContainer
|
|
61
|
-
# @see Docker::Container.create
|
|
62
|
+
# @see ::Docker::Container.create
|
|
62
63
|
# @since 0.1.0
|
|
63
|
-
|
|
64
|
+
CREATE_CONTAINER_DEFINITION = ToolForge.define(:create_container) do
|
|
64
65
|
description 'Create a Docker container'
|
|
65
66
|
|
|
66
|
-
param :image,
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
param :image,
|
|
68
|
+
type: :string,
|
|
69
|
+
description: 'Image name to use (e.g., "ubuntu:22.04")'
|
|
70
|
+
|
|
71
|
+
param :name,
|
|
72
|
+
type: :string,
|
|
73
|
+
description: 'Container name (optional)',
|
|
74
|
+
required: false
|
|
75
|
+
|
|
76
|
+
param :cmd,
|
|
77
|
+
type: :string,
|
|
78
|
+
description: 'Command to run as space-separated string (optional, e.g., "npm start" or "python app.py")',
|
|
79
|
+
required: false
|
|
80
|
+
|
|
69
81
|
param :env,
|
|
70
|
-
|
|
71
|
-
|
|
82
|
+
type: :string,
|
|
83
|
+
description: 'Environment variables as comma-separated KEY=VALUE pairs (optional)',
|
|
72
84
|
required: false
|
|
73
|
-
param :exposed_ports, desc: 'Exposed ports as JSON object (optional)', required: false
|
|
74
|
-
param :host_config, desc: 'Host configuration including port bindings, volumes, etc. as JSON object (optional)',
|
|
75
|
-
required: false
|
|
76
85
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
# @param env [String, nil] environment variables as comma-separated KEY=VALUE pairs
|
|
89
|
-
# @param exposed_ports [Hash, nil] ports to expose in {"port/protocol" => {}} format
|
|
90
|
-
# @param host_config [Hash, nil] Docker host configuration including bindings and volumes
|
|
91
|
-
#
|
|
92
|
-
# @return [RubyLLM::Tool::Response] creation results with container ID and name
|
|
93
|
-
#
|
|
94
|
-
# @raise [Docker::Error::NotFoundError] if the specified image doesn't exist
|
|
95
|
-
# @raise [Docker::Error::ConflictError] if container name already exists
|
|
96
|
-
# @raise [StandardError] for other creation failures
|
|
97
|
-
#
|
|
98
|
-
# @example Create simple container
|
|
99
|
-
# response = CreateContainer.call(
|
|
100
|
-
# server_context: context,
|
|
101
|
-
# image: "alpine:latest",
|
|
102
|
-
# name: "test-container"
|
|
103
|
-
# )
|
|
104
|
-
#
|
|
105
|
-
# @example Create container with full configuration
|
|
106
|
-
# response = CreateContainer.call(
|
|
107
|
-
# server_context: context,
|
|
108
|
-
# image: "redis:7-alpine",
|
|
109
|
-
# name: "redis-cache",
|
|
110
|
-
# env: "REDIS_PASSWORD=secret",
|
|
111
|
-
# exposed_ports: {"6379/tcp" => {}},
|
|
112
|
-
# host_config: {
|
|
113
|
-
# "PortBindings" => {"6379/tcp" => [{"HostPort" => "6379"}]},
|
|
114
|
-
# "RestartPolicy" => {"Name" => "unless-stopped"}
|
|
115
|
-
# }
|
|
116
|
-
# )
|
|
117
|
-
#
|
|
118
|
-
# @see Docker::Container.create
|
|
119
|
-
def execute(image:, name: nil, cmd: nil, env: nil, exposed_ports: nil, host_config: nil)
|
|
86
|
+
param :exposed_ports,
|
|
87
|
+
type: :object,
|
|
88
|
+
description: 'Exposed ports as {"port/protocol": {}} (optional)',
|
|
89
|
+
required: false
|
|
90
|
+
|
|
91
|
+
param :host_config,
|
|
92
|
+
type: :object,
|
|
93
|
+
description: 'Host configuration including port bindings, volumes, etc. (optional)',
|
|
94
|
+
required: false
|
|
95
|
+
|
|
96
|
+
execute do |image:, name: nil, cmd: nil, env: nil, exposed_ports: nil, host_config: nil|
|
|
120
97
|
config = { 'Image' => image }
|
|
121
98
|
config['name'] = name if name
|
|
122
|
-
config['Cmd'] = cmd if cmd
|
|
123
99
|
|
|
124
|
-
# Parse
|
|
125
|
-
if
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
100
|
+
# Parse cmd string into array if provided
|
|
101
|
+
config['Cmd'] = Shellwords.split(cmd) if cmd && !cmd.strip.empty?
|
|
102
|
+
|
|
103
|
+
# Parse env string into array if provided
|
|
104
|
+
config['Env'] = env.split(',').map(&:strip) if env && !env.strip.empty?
|
|
129
105
|
|
|
130
106
|
config['ExposedPorts'] = exposed_ports if exposed_ports
|
|
131
107
|
config['HostConfig'] = host_config if host_config
|
|
@@ -142,5 +118,7 @@ module RubyLLM
|
|
|
142
118
|
"Error creating container: #{e.message}"
|
|
143
119
|
end
|
|
144
120
|
end
|
|
121
|
+
|
|
122
|
+
CreateContainer = CREATE_CONTAINER_DEFINITION.to_ruby_llm_tool
|
|
145
123
|
end
|
|
146
124
|
end
|
|
@@ -2,116 +2,98 @@
|
|
|
2
2
|
|
|
3
3
|
module RubyLLM
|
|
4
4
|
module Docker
|
|
5
|
-
#
|
|
5
|
+
# MCP tool for creating Docker networks.
|
|
6
6
|
#
|
|
7
|
-
# This tool provides the ability to create custom Docker networks
|
|
8
|
-
# container communication and isolation. Networks enable
|
|
9
|
-
#
|
|
10
|
-
# segments.
|
|
7
|
+
# This tool provides the ability to create custom Docker networks
|
|
8
|
+
# for container communication and isolation. Networks enable secure
|
|
9
|
+
# and controlled communication between containers and external systems.
|
|
11
10
|
#
|
|
12
11
|
# == Features
|
|
13
12
|
#
|
|
14
13
|
# - Create custom Docker networks
|
|
15
|
-
# - Support for
|
|
16
|
-
# - Duplicate name
|
|
14
|
+
# - Support for multiple network drivers (bridge, overlay, host, etc.)
|
|
15
|
+
# - Duplicate name checking and validation
|
|
16
|
+
# - Network configuration and options
|
|
17
17
|
# - Comprehensive error handling
|
|
18
|
-
# -
|
|
19
|
-
#
|
|
20
|
-
# == Network Drivers
|
|
21
|
-
#
|
|
22
|
-
# Docker supports various network drivers:
|
|
23
|
-
# - **bridge**: Default isolated network for single-host networking
|
|
24
|
-
# - **host**: Remove network isolation, use host networking directly
|
|
25
|
-
# - **overlay**: Multi-host networking for swarm services
|
|
26
|
-
# - **macvlan**: Assign MAC addresses to containers
|
|
27
|
-
# - **none**: Disable networking completely
|
|
28
|
-
# - **Custom**: Third-party network drivers
|
|
18
|
+
# - Network isolation and security controls
|
|
29
19
|
#
|
|
30
20
|
# == Security Considerations
|
|
31
21
|
#
|
|
32
|
-
# Network creation
|
|
33
|
-
# - **Network Isolation**:
|
|
34
|
-
# - **Traffic Control**:
|
|
35
|
-
# - **Access
|
|
36
|
-
# - **
|
|
22
|
+
# Network creation involves important security considerations:
|
|
23
|
+
# - **Network Isolation**: Improper networks can compromise container isolation
|
|
24
|
+
# - **Traffic Control**: Networks affect inter-container communication
|
|
25
|
+
# - **External Access**: Bridge networks may expose containers externally
|
|
26
|
+
# - **Resource Usage**: Networks consume system resources
|
|
27
|
+
# - **DNS Resolution**: Custom networks affect service discovery
|
|
28
|
+
# - **Firewall Bypass**: Networks can bypass host firewall rules
|
|
37
29
|
#
|
|
38
|
-
# Security
|
|
39
|
-
# -
|
|
40
|
-
# - Host networks expose containers to all host traffic
|
|
41
|
-
# - Custom networks should follow least-privilege principles
|
|
42
|
-
# - Network names may reveal infrastructure details
|
|
43
|
-
#
|
|
44
|
-
# Best practices:
|
|
45
|
-
# - Use descriptive but not sensitive network names
|
|
30
|
+
# **Security Recommendations**:
|
|
31
|
+
# - Use appropriate network drivers for use case
|
|
46
32
|
# - Implement network segmentation strategies
|
|
47
|
-
# -
|
|
48
|
-
# -
|
|
33
|
+
# - Monitor network traffic and usage
|
|
34
|
+
# - Avoid exposing internal networks externally
|
|
35
|
+
# - Use network policies for access control
|
|
49
36
|
# - Regular audit of network configurations
|
|
50
37
|
#
|
|
38
|
+
# == Parameters
|
|
39
|
+
#
|
|
40
|
+
# - **name**: Name of the network (required)
|
|
41
|
+
# - **driver**: Driver to use (optional, default: "bridge")
|
|
42
|
+
# - **check_duplicate**: Check for networks with duplicate names (optional, default: true)
|
|
43
|
+
#
|
|
44
|
+
# == Network Drivers
|
|
45
|
+
#
|
|
46
|
+
# - **bridge**: Default driver for single-host networking
|
|
47
|
+
# - **overlay**: Multi-host networking for Docker Swarm
|
|
48
|
+
# - **host**: Uses host's network stack directly
|
|
49
|
+
# - **none**: Disables networking for containers
|
|
50
|
+
# - **macvlan**: Assigns MAC addresses to containers
|
|
51
|
+
#
|
|
51
52
|
# == Example Usage
|
|
52
53
|
#
|
|
53
54
|
# # Create basic bridge network
|
|
54
|
-
# CreateNetwork.call(
|
|
55
|
+
# response = CreateNetwork.call(
|
|
55
56
|
# server_context: context,
|
|
56
57
|
# name: "app-network"
|
|
57
58
|
# )
|
|
58
59
|
#
|
|
59
|
-
# # Create network
|
|
60
|
-
# CreateNetwork.call(
|
|
60
|
+
# # Create overlay network for swarm
|
|
61
|
+
# response = CreateNetwork.call(
|
|
61
62
|
# server_context: context,
|
|
62
|
-
# name: "
|
|
63
|
-
# driver: "
|
|
63
|
+
# name: "swarm-network",
|
|
64
|
+
# driver: "overlay"
|
|
64
65
|
# )
|
|
65
66
|
#
|
|
66
|
-
# # Create
|
|
67
|
-
# CreateNetwork.call(
|
|
67
|
+
# # Create network allowing duplicates
|
|
68
|
+
# response = CreateNetwork.call(
|
|
68
69
|
# server_context: context,
|
|
69
|
-
# name: "
|
|
70
|
+
# name: "test-network",
|
|
71
|
+
# driver: "bridge",
|
|
70
72
|
# check_duplicate: false
|
|
71
73
|
# )
|
|
72
74
|
#
|
|
73
|
-
# @see
|
|
74
|
-
# @see RemoveNetwork
|
|
75
|
-
# @see Docker::Network.create
|
|
75
|
+
# @see ::Docker::Network.create
|
|
76
76
|
# @since 0.1.0
|
|
77
|
-
|
|
77
|
+
CREATE_NETWORK_DEFINITION = ToolForge.define(:create_network) do
|
|
78
78
|
description 'Create a Docker network'
|
|
79
79
|
|
|
80
|
-
param :name,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
required: false
|
|
80
|
+
param :name,
|
|
81
|
+
type: :string,
|
|
82
|
+
description: 'Name of the network'
|
|
84
83
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
# @raise [Docker::Error::ConflictError] if network name already exists
|
|
99
|
-
# @raise [StandardError] for other network creation failures
|
|
100
|
-
#
|
|
101
|
-
# @example Create application network
|
|
102
|
-
# response = CreateNetwork.call(
|
|
103
|
-
# server_context: context,
|
|
104
|
-
# name: "webapp-network"
|
|
105
|
-
# )
|
|
106
|
-
#
|
|
107
|
-
# @example Create host network
|
|
108
|
-
# response = tool.execute(
|
|
109
|
-
# name: "high-performance-net",
|
|
110
|
-
# driver: "host"
|
|
111
|
-
# )
|
|
112
|
-
#
|
|
113
|
-
# @see Docker::Network.create
|
|
114
|
-
def execute(name:, driver: 'bridge', check_duplicate: true)
|
|
84
|
+
param :driver,
|
|
85
|
+
type: :string,
|
|
86
|
+
description: 'Driver to use (default: bridge)',
|
|
87
|
+
required: false,
|
|
88
|
+
default: 'bridge'
|
|
89
|
+
|
|
90
|
+
param :check_duplicate,
|
|
91
|
+
type: :boolean,
|
|
92
|
+
description: 'Check for networks with duplicate names (default: true)',
|
|
93
|
+
required: false,
|
|
94
|
+
default: true
|
|
95
|
+
|
|
96
|
+
execute do |name:, driver: 'bridge', check_duplicate: true|
|
|
115
97
|
options = {
|
|
116
98
|
'Name' => name,
|
|
117
99
|
'Driver' => driver,
|
|
@@ -127,5 +109,7 @@ module RubyLLM
|
|
|
127
109
|
"Error creating network: #{e.message}"
|
|
128
110
|
end
|
|
129
111
|
end
|
|
112
|
+
|
|
113
|
+
CreateNetwork = CREATE_NETWORK_DEFINITION.to_ruby_llm_tool
|
|
130
114
|
end
|
|
131
115
|
end
|
|
@@ -2,115 +2,91 @@
|
|
|
2
2
|
|
|
3
3
|
module RubyLLM
|
|
4
4
|
module Docker
|
|
5
|
-
#
|
|
5
|
+
# MCP tool for creating Docker volumes.
|
|
6
6
|
#
|
|
7
|
-
# This tool provides the ability to create
|
|
8
|
-
# data storage
|
|
9
|
-
#
|
|
10
|
-
# containers.
|
|
7
|
+
# This tool provides the ability to create Docker volumes for persistent
|
|
8
|
+
# data storage. Volumes are essential for maintaining data across container
|
|
9
|
+
# lifecycles and enabling data sharing between containers.
|
|
11
10
|
#
|
|
12
11
|
# == Features
|
|
13
12
|
#
|
|
14
|
-
# - Create named
|
|
15
|
-
# - Support for
|
|
13
|
+
# - Create named Docker volumes
|
|
14
|
+
# - Support for multiple volume drivers
|
|
15
|
+
# - Persistent data storage management
|
|
16
|
+
# - Volume driver configuration
|
|
16
17
|
# - Comprehensive error handling
|
|
17
|
-
# -
|
|
18
|
-
# - Flexible storage configuration
|
|
18
|
+
# - Volume lifecycle management
|
|
19
19
|
#
|
|
20
|
-
# ==
|
|
21
|
-
#
|
|
22
|
-
# Docker supports various volume drivers:
|
|
23
|
-
# - **local**: Default driver using host filesystem
|
|
24
|
-
# - **nfs**: Network File System for shared storage
|
|
25
|
-
# - **cifs**: Common Internet File System
|
|
26
|
-
# - **rexray**: External storage orchestration
|
|
27
|
-
# - **Custom**: Third-party volume drivers
|
|
20
|
+
# == Security Considerations
|
|
28
21
|
#
|
|
29
|
-
#
|
|
22
|
+
# Volume creation involves important security considerations:
|
|
23
|
+
# - **Data Persistence**: Volumes store data beyond container lifecycle
|
|
24
|
+
# - **Access Control**: Volume permissions affect data security
|
|
25
|
+
# - **Data Isolation**: Improper volumes can compromise data separation
|
|
26
|
+
# - **Storage Security**: Volume drivers may have security implications
|
|
27
|
+
# - **Resource Usage**: Volumes consume disk space and system resources
|
|
28
|
+
# - **Data Leakage**: Shared volumes can expose sensitive data
|
|
30
29
|
#
|
|
31
|
-
#
|
|
32
|
-
# -
|
|
33
|
-
# -
|
|
34
|
-
# -
|
|
35
|
-
# -
|
|
36
|
-
# -
|
|
37
|
-
# -
|
|
30
|
+
# **Security Recommendations**:
|
|
31
|
+
# - Use appropriate volume drivers for security requirements
|
|
32
|
+
# - Implement proper access controls and permissions
|
|
33
|
+
# - Monitor volume usage and capacity
|
|
34
|
+
# - Regular backup of critical volume data
|
|
35
|
+
# - Audit volume access patterns
|
|
36
|
+
# - Use encryption for sensitive data volumes
|
|
37
|
+
# - Implement volume lifecycle policies
|
|
38
38
|
#
|
|
39
|
-
# ==
|
|
39
|
+
# == Parameters
|
|
40
40
|
#
|
|
41
|
-
#
|
|
42
|
-
# - **
|
|
43
|
-
# - **Access Control**: Volume permissions affect data access
|
|
44
|
-
# - **Storage Location**: Local volumes stored on host filesystem
|
|
45
|
-
# - **Shared Access**: Multiple containers can access the same volume
|
|
41
|
+
# - **name**: Name of the volume (required)
|
|
42
|
+
# - **driver**: Driver to use (optional, default: "local")
|
|
46
43
|
#
|
|
47
|
-
#
|
|
48
|
-
# - Volumes persist data beyond container lifecycle
|
|
49
|
-
# - Volume names may reveal application details
|
|
50
|
-
# - Shared volumes can leak data between containers
|
|
51
|
-
# - Storage driver choice affects security properties
|
|
44
|
+
# == Volume Drivers
|
|
52
45
|
#
|
|
53
|
-
#
|
|
54
|
-
# -
|
|
55
|
-
# -
|
|
56
|
-
# -
|
|
57
|
-
# -
|
|
58
|
-
# - Choose appropriate drivers for security requirements
|
|
46
|
+
# - **local**: Default driver for local filesystem storage
|
|
47
|
+
# - **nfs**: Network File System driver for shared storage
|
|
48
|
+
# - **cifs**: Common Internet File System driver
|
|
49
|
+
# - **rexray**: REX-Ray driver for cloud storage integration
|
|
50
|
+
# - **convoy**: Convoy driver for snapshot management
|
|
59
51
|
#
|
|
60
52
|
# == Example Usage
|
|
61
53
|
#
|
|
62
54
|
# # Create basic local volume
|
|
63
|
-
# CreateVolume.call(
|
|
55
|
+
# response = CreateVolume.call(
|
|
64
56
|
# server_context: context,
|
|
65
57
|
# name: "app-data"
|
|
66
58
|
# )
|
|
67
59
|
#
|
|
68
60
|
# # Create volume with specific driver
|
|
69
|
-
# CreateVolume.call(
|
|
61
|
+
# response = CreateVolume.call(
|
|
70
62
|
# server_context: context,
|
|
71
63
|
# name: "shared-storage",
|
|
72
64
|
# driver: "nfs"
|
|
73
65
|
# )
|
|
74
66
|
#
|
|
75
|
-
#
|
|
76
|
-
#
|
|
77
|
-
#
|
|
67
|
+
# # Create database volume
|
|
68
|
+
# response = CreateVolume.call(
|
|
69
|
+
# server_context: context,
|
|
70
|
+
# name: "postgres-data",
|
|
71
|
+
# driver: "local"
|
|
72
|
+
# )
|
|
73
|
+
#
|
|
74
|
+
# @see ::Docker::Volume.create
|
|
78
75
|
# @since 0.1.0
|
|
79
|
-
|
|
76
|
+
CREATE_VOLUME_DEFINITION = ToolForge.define(:create_volume) do
|
|
80
77
|
description 'Create a Docker volume'
|
|
81
78
|
|
|
82
|
-
param :name,
|
|
83
|
-
|
|
79
|
+
param :name,
|
|
80
|
+
type: :string,
|
|
81
|
+
description: 'Name of the volume'
|
|
82
|
+
|
|
83
|
+
param :driver,
|
|
84
|
+
type: :string,
|
|
85
|
+
description: 'Driver to use (default: local)',
|
|
86
|
+
required: false,
|
|
87
|
+
default: 'local'
|
|
84
88
|
|
|
85
|
-
|
|
86
|
-
#
|
|
87
|
-
# This method creates a named Docker volume that can be used by containers
|
|
88
|
-
# for persistent data storage. The volume will survive container deletion
|
|
89
|
-
# and can be shared between multiple containers.
|
|
90
|
-
#
|
|
91
|
-
# @param name [String] name for the new volume
|
|
92
|
-
# @param server_context [Object] RubyLLM context (unused but required)
|
|
93
|
-
# @param driver [String] volume driver to use (default: "local")
|
|
94
|
-
#
|
|
95
|
-
# @return [RubyLLM::Tool::Response] volume creation results
|
|
96
|
-
#
|
|
97
|
-
# @raise [Docker::Error::ConflictError] if volume name already exists
|
|
98
|
-
# @raise [StandardError] for other volume creation failures
|
|
99
|
-
#
|
|
100
|
-
# @example Create application data volume
|
|
101
|
-
# response = CreateVolume.call(
|
|
102
|
-
# server_context: context,
|
|
103
|
-
# name: "webapp-data"
|
|
104
|
-
# )
|
|
105
|
-
#
|
|
106
|
-
# @example Create NFS volume
|
|
107
|
-
# response = tool.execute(
|
|
108
|
-
# name: "shared-files",
|
|
109
|
-
# driver: "nfs"
|
|
110
|
-
# )
|
|
111
|
-
#
|
|
112
|
-
# @see Docker::Volume.create
|
|
113
|
-
def execute(name:, driver: 'local')
|
|
89
|
+
execute do |name:, driver: 'local'|
|
|
114
90
|
options = {
|
|
115
91
|
'Name' => name,
|
|
116
92
|
'Driver' => driver
|
|
@@ -125,5 +101,7 @@ module RubyLLM
|
|
|
125
101
|
"Error creating volume: #{e.message}"
|
|
126
102
|
end
|
|
127
103
|
end
|
|
104
|
+
|
|
105
|
+
CreateVolume = CREATE_VOLUME_DEFINITION.to_ruby_llm_tool
|
|
128
106
|
end
|
|
129
107
|
end
|