API-Docker
view release on metacpan or search on metacpan
lib/API/Docker/Container.pm view on Meta::CPAN
=head1 NAME
API::Docker::Container - Docker container entity
=head1 VERSION
version 0.002
=head1 SYNOPSIS
my $docker = API::Docker->new;
# Get container from list or inspect
my $containers = $docker->containers->list;
my $container = $containers->[0];
# Access container properties
say $container->Id;
say $container->Status;
say $container->Image;
# Perform operations
$container->start;
$container->stop(timeout => 10);
my $logs = $container->logs(tail => 100);
$container->remove(force => 1);
# Check state
if ($container->is_running) {
say "Container is running";
}
=head1 DESCRIPTION
This class represents a Docker container and provides convenient access to
container properties and operations. Instances are returned by
L<API::Docker::API::Containers> methods like C<list> and C<inspect>.
Each attribute corresponds to fields in the Docker API container representation.
Methods delegate to L<API::Docker::API::Containers> for operations.
=head2 client
Reference to L<API::Docker> client. Used for delegating operations.
=head2 Id
Container ID (64-character hex string).
=head2 Names
ArrayRef of container names (from C<list>).
=head2 Image
Image name used to create the container.
=head2 Created
Container creation timestamp (Unix epoch).
=head2 State
Container state. From C<list>: string like C<running>, C<exited>. From
C<inspect>: hashref with C<Running>, C<Paused>, C<ExitCode>, etc.
=head2 Status
Human-readable status string (e.g., "Up 2 hours").
=head2 Name
Container name (from C<inspect>, includes leading C</>).
=head2 start
$container->start;
Start the container. Delegates to L<API::Docker::API::Containers/start>.
=head2 stop
$container->stop(timeout => 10);
Stop the container. Delegates to L<API::Docker::API::Containers/stop>.
=head2 restart
$container->restart;
Restart the container.
=head2 kill
$container->kill(signal => 'SIGTERM');
Send a signal to the container.
=head2 remove
$container->remove(force => 1);
Remove the container.
=head2 logs
my $logs = $container->logs(tail => 100);
Get container logs.
=head2 inspect
my $updated = $container->inspect;
Get fresh container information.
=head2 pause
$container->pause;
( run in 0.445 second using v1.01-cache-2.11-cpan-64ef6c95b5d )