clone
docker.volume.clone(source, new_volume_name=None, driver=None, labels={}, options={})
Clone a volume.
Arguments
- source
Union[python_on_whales.Volume, str]
: The volume to clone - new_volume_name
Optional[str]
: The new volume name. If not given, a random name is chosen. - driver
Optional[str]
: Specify volume driver name (default "local") - labels
Dict[str, str]
: Set metadata for a volume - options
Dict[str, str]
: Set driver specific options
Returns
A python_on_whales.Volume
, the new volume.
copy
docker.volume.copy(source, destination)
Copy files/folders between a volume and the local filesystem.
Arguments
- source
Union[str, pathlib.Path, Tuple[Union[python_on_whales.Volume, str], Union[str, pathlib.Path]]]
: Ifsource
is a directory/file inside a Docker volume, a tuple(my_volume, path_in_volume)
must be provided. The volume can be apython_on_whales.Volume
or a volume name asstr
. The path can be apathlib.Path
or astr
. Ifsource
is a local directory, apathlib.Path
orstr
should be provided. End the source path with/.
if you want to copy the directory content in another directory. - destination
Union[str, pathlib.Path, Tuple[Union[python_on_whales.Volume, str], Union[str, pathlib.Path]]]
: Same assource
.
create
docker.volume.create(volume_name=None, driver=None, labels={}, options={})
Creates a volume
Arguments
- volume_name
Optional[str]
: The volume name, if not provided, a long random string will be used instead. - driver
Optional[str]
: Specify volume driver name (default "local") - labels
Dict[str, str]
: Set metadata for a volume - options
Dict[str, str]
: Set driver specific options
exists
docker.volume.exists(x)
Returns True
if the volume exists. False
otherwise.
It's just calling docker.volume.inspect(...)
and verifies that it doesn't throw
a python_on_whales.exceptions.NoSuchVolume
.
Returns
A bool
inspect
docker.volume.inspect(x)
list
docker.volume.list(filters={})
List volumes
Arguments
- filters
Dict[str, Union[str, int]]
: See the Docker documentation page about filtering . An examplefilters=dict(dangling=1, driver="local")
.
Returns
List[python_on_whales.Volume]
prune
docker.volume.prune(filters={})
Remove volumes
Arguments
- filters
Dict[str, Union[str, int]]
: See the Docker documentation page about filtering . An examplefilters=dict(dangling=1, driver="local")
.
remove
docker.volume.remove(x)
Removes one or more volumes
Arguments
- x
Union[python_on_whales.Volume, str, List[Union[python_on_whales.Volume, str]]]
: A volume or a list of volumes. An empty list as argument means nothing is done.