class documentation

class VolumeApiMixin: (source)

Known subclasses: docker.api.client.APIClient

View In Hierarchy

Undocumented

Method create_volume Create and register a named volume
Method inspect_volume Retrieve volume info by name.
Method prune_volumes Delete unused volumes
Method remove_volume Remove a volume. Similar to the ``docker volume rm`` command.
Method volumes List volumes currently registered by the docker daemon. Similar to the ``docker volume ls`` command.
def create_volume(self, name=None, driver=None, driver_opts=None, labels=None): (source)

Create and register a named volume Args: name (str): Name of the volume driver (str): Name of the driver used to create the volume driver_opts (dict): Driver options as a key-value dictionary labels (dict): Labels to set on the volume Returns: (dict): The created volume reference object Raises: :py:class:`docker.errors.APIError` If the server returns an error. Example: >>> volume = client.api.create_volume( ... name='foobar', ... driver='local', ... driver_opts={'foo': 'bar', 'baz': 'false'}, ... labels={"key": "value"}, ... ) ... print(volume) {u'Driver': u'local', u'Labels': {u'key': u'value'}, u'Mountpoint': u'/var/lib/docker/volumes/foobar/_data', u'Name': u'foobar', u'Scope': u'local'}

def inspect_volume(self, name): (source)

Retrieve volume info by name. Args: name (str): volume name Returns: (dict): Volume information dictionary Raises: :py:class:`docker.errors.APIError` If the server returns an error. Example: >>> client.api.inspect_volume('foobar') {u'Driver': u'local', u'Mountpoint': u'/var/lib/docker/volumes/foobar/_data', u'Name': u'foobar'}

@utils.minimum_version('1.25')
def prune_volumes(self, filters=None): (source)

Delete unused volumes Args: filters (dict): Filters to process on the prune list. Returns: (dict): A dict containing a list of deleted volume names and the amount of disk space reclaimed in bytes. Raises: :py:class:`docker.errors.APIError` If the server returns an error.

def remove_volume(self, name, force=False): (source)

Remove a volume. Similar to the ``docker volume rm`` command. Args: name (str): The volume's name force (bool): Force removal of volumes that were already removed out of band by the volume driver plugin. Raises: :py:class:`docker.errors.APIError` If volume failed to remove.

def volumes(self, filters=None): (source)

List volumes currently registered by the docker daemon. Similar to the ``docker volume ls`` command. Args: filters (dict): Server-side list filtering options. Returns: (dict): Dictionary with list of volume objects as value of the ``Volumes`` key. Raises: :py:class:`docker.errors.APIError` If the server returns an error. Example: >>> client.api.volumes() {u'Volumes': [{u'Driver': u'local', u'Mountpoint': u'/var/lib/docker/volumes/foobar/_data', u'Name': u'foobar'}, {u'Driver': u'local', u'Mountpoint': u'/var/lib/docker/volumes/baz/_data', u'Name': u'baz'}]}