NAME
API::Docker::API::Networks - Docker Engine Networks API
VERSION
version 0.004
SYNOPSIS
my $docker = API::Docker->new;
# Create a network
my $result = $docker->networks->create(
Name => 'my-network',
Driver => 'bridge',
);
# List networks
my $networks = $docker->networks->list;
say $_->name, ' ', $_->driver for @$networks;
# Connect/disconnect containers
$docker->networks->connect($network_id, Container => $container_id);
$docker->networks->disconnect($network_id, Container => $container_id);
# Remove network
$docker->networks->remove($network_id);
DESCRIPTION
This module provides methods for managing Docker networks including creation, listing, connecting containers, and removal.
"list" and "inspect" both return API::Docker::Type::Network objects carrying the convenience methods of API::Docker::Role::Entity::Network, so $network->connect and $network->remove work on either. The field names are the swagger's own spelling in snake_case: Id is ->id, EnableIPv6 is ->enable_ipv6, and IPAM is ->ipam, an API::Docker::Type::IPAM whose ->config is an ArrayRef of API::Docker::Type::IPAMConfig.
Unlike containers and images this is one class for both calls: the swagger answers GET /networks and GET /networks/{id} with the same Network definition, so there is no list-versus-inspect shape to keep apart -- see "One class, not two" in API::Docker::Role::Entity::Network.
Accessed via $docker->networks, or through "using" in API::Docker::Role::Using for a run of calls that needs its own transport bound: $docker->networks->using(read_timeout => 5).
client
Reference to API::Docker client. Weak reference to avoid circular dependencies.
list
my $networks = $networks->list;
my $bridges = $networks->list(filters => { driver => ['bridge'] });
List networks. Returns an ArrayRef of API::Docker::Type::Network objects, each carrying the methods of API::Docker::Role::Entity::Network.
Options:
filters- HashRef of filter name to ArrayRef of string values; the engine acceptsdangling,driver,id,label,name,scopeandtypehere. Shape-checked and normalised by API::Docker::Role::Filters
inspect
my $network = $networks->inspect($id);
Get detailed information about a network. Returns an API::Docker::Type::Network -- the same class "list" returns, since the swagger describes a network one way.
create
my $result = $networks->create(
Name => 'my-network',
Driver => 'bridge',
);
Create a network. Returns hashref with Id and Warning.
Boolean flags (Internal, Attachable, Ingress, ConfigOnly, EnableIPv4, EnableIPv6) may be given as a Perl 1/0 or as a JSON boolean; either goes out as a real JSON true/false, which the engine's body type-check requires.
remove
$networks->remove($id);
Remove a network.
connect
$networks->connect($network_id, Container => $container_id);
Connect a container to a network.
disconnect
$networks->disconnect($network_id, Container => $container_id, Force => 1);
Disconnect a container from a network. Optional Force parameter, given as a Perl 1/0 or a JSON boolean; it goes out as a real JSON true/false, which the engine's body type-check requires.
prune
my $result = $networks->prune;
my $result = $networks->prune(filters => { until => ['24h'] });
Delete unused networks. Returns hashref with NetworksDeleted.
Options:
filters- HashRef of filter name to ArrayRef of string values; the engine acceptsuntilandlabelhere. Shape-checked and normalised by API::Docker::Role::Filters
SEE ALSO
API::Docker - Main Docker client
API::Docker::Role::Entity::Network - the convenience methods the returned objects carry
API::Docker::Type::Network - the fields
listandinspectreturn
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.