0
# Plugin Management
1
2
Docker plugin installation, configuration, and lifecycle management with support for volume drivers, network drivers, and custom plugin development.
3
4
## Capabilities
5
6
### PluginCollection
7
8
```python { .api }
9
class PluginCollection:
10
def create(self, **kwargs):
11
"""
12
Create a plugin from a rootfs and config.
13
14
Args:
15
**kwargs: Plugin creation options
16
17
Returns:
18
Plugin: Created plugin instance
19
20
Common kwargs:
21
name (str): Plugin name
22
plugin_data_dir (str): Path to plugin data
23
"""
24
25
def get(self, name):
26
"""
27
Get a plugin by name.
28
29
Args:
30
name (str): Plugin name
31
32
Returns:
33
Plugin: Plugin instance
34
"""
35
36
def list(self, filters=None):
37
"""
38
List plugins.
39
40
Args:
41
filters (dict): Filter results by capability, enable status
42
43
Returns:
44
list[Plugin]: List of plugin instances
45
"""
46
47
def install(self, remote_name, local_name=None):
48
"""
49
Install a plugin from Docker Hub or registry.
50
51
Args:
52
remote_name (str): Remote plugin name
53
local_name (str): Local name for plugin
54
55
Returns:
56
Plugin: Installed plugin instance
57
"""
58
```
59
60
### Plugin Model
61
62
```python { .api }
63
class Plugin:
64
"""
65
A Docker plugin instance.
66
67
Properties:
68
id (str): Plugin ID
69
name (str): Plugin name
70
enabled (bool): Plugin enabled status
71
attrs (dict): Raw plugin attributes
72
"""
73
74
def configure(self, options):
75
"""
76
Configure plugin options.
77
78
Args:
79
options (dict): Plugin configuration options
80
"""
81
82
def disable(self, **kwargs):
83
"""
84
Disable the plugin.
85
86
Args:
87
**kwargs: Disable options (force)
88
"""
89
90
def enable(self, timeout=0):
91
"""
92
Enable the plugin.
93
94
Args:
95
timeout (int): Timeout for enable operation
96
"""
97
98
def push(self, **kwargs):
99
"""Push plugin to registry."""
100
101
def remove(self, **kwargs):
102
"""
103
Remove the plugin.
104
105
Args:
106
**kwargs: Remove options (force, v)
107
"""
108
109
def upgrade(self, **kwargs):
110
"""
111
Upgrade the plugin.
112
113
Args:
114
**kwargs: Upgrade options
115
"""
116
```
117
118
## Usage Examples
119
120
```python
121
import docker
122
123
client = docker.from_env()
124
125
# Install volume plugin
126
plugin = client.plugins.install('vieux/sshfs')
127
128
# Configure plugin
129
plugin.configure({'sshkey.source': '/home/user/.ssh/id_rsa'})
130
131
# Enable plugin
132
plugin.enable()
133
134
# Use plugin with volume
135
volume = client.volumes.create(
136
name='ssh-volume',
137
driver='vieux/sshfs:latest',
138
driver_opts={
139
'sshcmd': 'user@server:/path',
140
'allow_other': ''
141
}
142
)
143
```