class VolumeCollection(Collection): (source)
Volumes on the Docker server.
Method | create |
Create a volume. |
Method | get |
Get a volume. |
Method | list |
List volumes. Similar to the ``docker volume ls`` command. |
Method | prune |
Undocumented |
Inherited from Collection
:
Method | __call__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | prepare |
Create a model from a set of attributes. |
Class Variable | model |
Undocumented |
Instance Variable | client |
Undocumented |
docker.models.resource.Collection.create
Create a volume. Args: name (str): Name of the volume. If not specified, the engine generates a name. 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: (:py:class:`Volume`): The volume created. Raises: :py:class:`docker.errors.APIError` If the server returns an error. Example: >>> volume = client.volumes.create(name='foobar', driver='local', driver_opts={'foo': 'bar', 'baz': 'false'}, labels={"key": "value"})
docker.models.resource.Collection.get
Get a volume. Args: volume_id (str): Volume name. Returns: (:py:class:`Volume`): The volume. Raises: :py:class:`docker.errors.NotFound` If the volume does not exist. :py:class:`docker.errors.APIError` If the server returns an error.
docker.models.resource.Collection.list
List volumes. Similar to the ``docker volume ls`` command. Args: filters (dict): Server-side list filtering options. Returns: (list of :py:class:`Volume`): The volumes. Raises: :py:class:`docker.errors.APIError` If the server returns an error.