A Python library for the Docker Engine API.
—
Docker plugin installation, configuration, and lifecycle management with support for volume drivers, network drivers, and custom plugin development.
class PluginCollection:
def create(self, **kwargs):
"""
Create a plugin from a rootfs and config.
Args:
**kwargs: Plugin creation options
Returns:
Plugin: Created plugin instance
Common kwargs:
name (str): Plugin name
plugin_data_dir (str): Path to plugin data
"""
def get(self, name):
"""
Get a plugin by name.
Args:
name (str): Plugin name
Returns:
Plugin: Plugin instance
"""
def list(self, filters=None):
"""
List plugins.
Args:
filters (dict): Filter results by capability, enable status
Returns:
list[Plugin]: List of plugin instances
"""
def install(self, remote_name, local_name=None):
"""
Install a plugin from Docker Hub or registry.
Args:
remote_name (str): Remote plugin name
local_name (str): Local name for plugin
Returns:
Plugin: Installed plugin instance
"""class Plugin:
"""
A Docker plugin instance.
Properties:
id (str): Plugin ID
name (str): Plugin name
enabled (bool): Plugin enabled status
attrs (dict): Raw plugin attributes
"""
def configure(self, options):
"""
Configure plugin options.
Args:
options (dict): Plugin configuration options
"""
def disable(self, **kwargs):
"""
Disable the plugin.
Args:
**kwargs: Disable options (force)
"""
def enable(self, timeout=0):
"""
Enable the plugin.
Args:
timeout (int): Timeout for enable operation
"""
def push(self, **kwargs):
"""Push plugin to registry."""
def remove(self, **kwargs):
"""
Remove the plugin.
Args:
**kwargs: Remove options (force, v)
"""
def upgrade(self, **kwargs):
"""
Upgrade the plugin.
Args:
**kwargs: Upgrade options
"""import docker
client = docker.from_env()
# Install volume plugin
plugin = client.plugins.install('vieux/sshfs')
# Configure plugin
plugin.configure({'sshkey.source': '/home/user/.ssh/id_rsa'})
# Enable plugin
plugin.enable()
# Use plugin with volume
volume = client.volumes.create(
name='ssh-volume',
driver='vieux/sshfs:latest',
driver_opts={
'sshcmd': 'user@server:/path',
'allow_other': ''
}
)