NAME
API::Docker::Role::Entity::Network - Network operations, on the generated network type
VERSION
version 0.004
SYNOPSIS
my $docker = API::Docker->new;
my ($network) = @{ $docker->networks->list };
say $network->name;
say $network->driver;
say $network->ipam->config->[0]->subnet;
$network->connect(Container => $container_id);
$network->disconnect(Container => $container_id);
$network->remove;
DESCRIPTION
The convenience methods of a network. This role is composed, at load time, into API::Docker::Type::Network, the generated class the daemon answers network requests with.
One class, not two
Unlike containers and images, a network has one shape. The swagger answers both GET /networks -- an array of them -- and GET /networks/{id} with the same Network definition, so "list" in API::Docker::API::Networks and "inspect" in API::Docker::API::Networks hand back the same class and nothing here has to tell two apart. What can still differ between the two calls is which fields the engine fills in, not which fields exist -- no network in t/fixtures/networks_list.json carries Containers at all, and a field the engine omits reads as undef rather than as a shape of its own.
Every method here forwards to API::Docker::API::Networks with the network's own id and returns whatever that method returns; the options are that method's options, undocumented here on purpose so there is one place to correct when the engine's are found to be something else.
Why the methods are a role applied to a generated class rather than a class of their own: "DESCRIPTION" in API::Docker::Role::Entity.
inspect
my $fresh = $network->inspect;
Get fresh network information. Returns another API::Docker::Type::Network -- the same class, since the daemon describes a network one way.
remove
$network->remove;
Remove the network.
connect
$network->connect(Container => $container_id);
Connect a container to this network.
disconnect
$network->disconnect(Container => $container_id, Force => 1);
Disconnect a container from this network.
SEE ALSO
API::Docker::API::Networks - the operations these forward to
API::Docker::Type::Network - the fields
listandinspectreturnAPI::Docker::Role::Entity - why the methods live in a role
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.