Docker plugins

Don't use the constructor directly. Instead use

from python_on_whales import docker

my_docker_plugin = docker.plugin.install("vieux/sshfs:latest")
# or
my_docker_plugin = docker.plugin.inspect("vieux/sshfs:latest")
# or
list_of_plugins = docker.plugins.list()

For type hints, use this

from python_on_whales import Plugin

def print_name(plugin: Plugin):
    print(plugin.name)

Attributes

It attributes are the same that you get with the command line: docker plugin inspect ...

To get a complete description of those attributes, you can take a look at the daemon api reference page and click on "200 No error".

An example is worth many lines of descriptions.

In [1]: from python_on_whales import docker

In [2]: plugin = docker.plugin.install("vieux/sshfs:latest")

In [4]: def super_print(obj):
   ...:     print(f"type = {type(obj)}, value = {obj}")
   ...:

In [4]: super_print(plugin.id)
type = <class 'str'>, value = 7beae314828a0d019a30c1f290de56cc89c92a69f72de37286c02271d3172612

In [5]: super_print(plugin.name)
type = <class 'str'>, value = mochoa/s3fs-volume-plugin:latest

In [6]: super_print(plugin.enabled)
type = <class 'bool'>, value = True

In [7]: super_print(plugin.settings)
type = <class 'python_on_whales.components.plugin.models.PluginSettings'>, value = mounts=[] env=['AWSACCESSKEYID=', 'AWSSECRETACCESSKEY=', 'DEFAULT_S3FSOPTS=nomultipart,use_path_request_style'] args=[] devices=[PluginDevice()]

In [8]: super_print(plugin.plugin_reference)
type = <class 'str'>, value = docker.io/mochoa/s3fs-volume-plugin:latest

In [9]: super_print(plugin.config)
type = <class 'python_on_whales.components.plugin.models.PluginConfig'>, value = docker_version='19.03.15' description='S3FS plugin for Docker v2.0.9' documentation='https://github.com/marcelo-ochoa/docker-volume-plugins/' interface=Interface() entrypoint=['/usr/bin/tini', '--', '/s3fs-volume-plugin'] work_dir=''

Methods

disable

Plugin.disable(force=False)

Disable this plugin


enable

Plugin.enable(timeout=None)

Enable this plugin


push

Plugin.push(disable_content_trust=True)

Push this plugin


reload

Plugin.reload()

remove

Plugin.remove(force=False)

Remove this plugin


set

Plugin.set(configuration)

Set the configuration for this plugin


upgrade

Plugin.upgrade(remote=None, disable_content_trust=True, skip_remote_check=False)

Upgrade this plugin