Skip to content

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 = 7d6f34a93b0d81e557855ddaba7824d234e3bd9392619cfe23506eb7cd40f3fb

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

Plugin

disable

disable(force=False)

Disable this plugin

enable

enable(timeout=None)

Enable this plugin

push

push(disable_content_trust=True)

Push this plugin

remove

remove(force=False)

Remove this plugin

set

set(configuration)

Set the configuration for this plugin

upgrade

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

Upgrade this plugin