NAME
API::Docker::API::Volumes - Docker Engine Volumes API
VERSION
version 0.004
SYNOPSIS
my $docker = API::Docker->new;
# Create a volume
my $volume = $docker->volumes->create(
Name => 'my-volume',
Driver => 'local',
);
# List volumes
my $volumes = $docker->volumes->list;
# Inspect volume
my $vol = $docker->volumes->inspect('my-volume');
say $vol->mountpoint;
# Remove volume
$docker->volumes->remove('my-volume');
DESCRIPTION
This module provides methods for managing Docker volumes including creation, listing, inspection, and removal.
"list", "inspect" and "create" all return API::Docker::Type::Volume objects carrying the convenience methods of API::Docker::Role::Entity::Volume, so $volume->remove works on any of them. The field names are the swagger's own spelling in snake_case: Mountpoint is ->mountpoint, CreatedAt is ->created_at, UsageData is ->usage_data and inflates into an API::Docker::Type::Volume::UsageData.
This is one class for all three calls, where containers and images have two: the swagger answers the inspect and the create with the Volume definition outright and the list with a VolumeListResponse whose Volumes is an array of that same definition -- see "One class for all three calls" in API::Docker::Role::Entity::Volume. A volume is also addressed by its ->name rather than by an id; it has none.
Accessed via $docker->volumes, or through "using" in API::Docker::Role::Using for a run of calls that needs its own transport bound: $docker->volumes->using(read_timeout => 5).
client
Reference to API::Docker client. Weak reference to avoid circular dependencies.
list
my $volumes = $volumes->list;
my $unused = $volumes->list(filters => { dangling => ['true'] });
List volumes. Returns an ArrayRef of API::Docker::Type::Volume objects, each carrying the methods of API::Docker::Role::Entity::Volume. The daemon answers this endpoint with a VolumeListResponse rather than a bare array; the Volumes key is what comes back here, and the Warnings beside it are dropped.
Options:
filters- HashRef of filter name to ArrayRef of string values; the engine acceptsdangling,driver,labelandnamehere. Shape-checked and normalised by API::Docker::Role::Filters
create
my $volume = $volumes->create(
Name => 'my-volume',
Driver => 'local',
);
Create a volume. Returns an API::Docker::Type::Volume -- the only creating method in this distribution that wraps its response, because the swagger answers POST /volumes/create with the same definition an inspect returns.
inspect
my $volume = $volumes->inspect('my-volume');
Get detailed information about a volume. Returns an API::Docker::Type::Volume -- the same class "list" and "create" return, since the swagger describes a volume one way.
remove
$volumes->remove('my-volume', force => 1);
Remove a volume. Optional force parameter.
prune
my $result = $volumes->prune;
my $result = $volumes->prune(filters => { label => ['stage=build'] });
Delete unused volumes. Returns hashref with VolumesDeleted and SpaceReclaimed.
Options:
filters- HashRef of filter name to ArrayRef of string values; the engine acceptslabelhere. Shape-checked and normalised by API::Docker::Role::Filters
SEE ALSO
API::Docker - Main Docker client
API::Docker::Role::Entity::Volume - the convenience methods the returned objects carry
API::Docker::Type::Volume - the fields
list,inspectandcreatereturn
SUPPORT
Issues
Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-api-docker/issues.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <getty@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.