App-Docker-Client
view release on metacpan or search on metacpan
lib/App/Docker/Client.pm view on Meta::CPAN
$self->_error_code( $response->code, $response->message, $response->content );
my $content = $response->content();
return $self->to_hashref($content);
}
=head2 _error_code
Simple error handler returns undef if everything is ok dies on error.
=cut
sub _error_code {
my ( $self, $code, $message, $content ) = @_;
return $code if $self->{_valid_codes}->{$code};
require Carp;
Carp::cluck;
Carp::croak "FAILURE: $code - " . qq~$message\n$content~;
}
}
1; # End of App::Docker::Client
__END__
=head1 SYNOPSIS
Sample to inspect a conatainer, for mor posibilities see at the Docker API
documentation L<https://docs.docker.com/engine/api/v1.25/>
use App::Docker::Client;
my $client = App::Docker::Client->new();
my $hash_ref = $client->get('/containers/<container_id>/json');
Create a new container:
$client->post('/containers/create', {}, {
Name => 'container_name',
Tty => 1,
OpenStdin => 1,
Image => 'perl',
});
For a remote authority engine use it like that:
use App::Docker::Client;
my %hash = ( authority => '0.0.0.0:5435' );
my $client = App::Docker::Client->new( %hash );
my $hash_ref = $client->get('/containers/<container_id>/json');
To follow logs
*STDOUT->autoflush(1);
my $cv = $client->attach(
'/containers/<container_id>/attach',
{ stream => 1, logs => 1, stdin => 1, stderr => 1, stdout => 1, tail => 50 },
\*STDIN,
\*STDOUT
);
$cv->recv;
=head1 AUTHOR
Mario Zieschang, C<< <mziescha at cpan.org> >>
=head1 BUGS
Please report any bugs or feature requests to C<bug-app-docker-client at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-Docker-Client>. I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc App::Docker::Client
You can also look for information at:
=over 4
=item * RT: CPAN's request tracker (report bugs here)
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-Docker-Client>
=item * AnnoCPAN: Annotated CPAN documentation
L<http://annocpan.org/dist/App-Docker-Client>
=item * CPAN Ratings
L<http://cpanratings.perl.org/d/App-Docker-Client>
=item * Search CPAN
L<http://search.cpan.org/dist/App-Docker-Client/>
=back
=head1 SEE ALSO
This package was partly inspired by L<Net::Docker> by Peter Stuifzand and
L<WWW::Docker> by Shane Utt but everyone has his own client and is
near similar.
=head1 LICENSE AND COPYRIGHT
Copyright 2017 Mario Zieschang.
This program is free software; you can redistribute it and/or modify it
under the terms of the the Artistic License (2.0). You may obtain a
copy of the full license at:
L<http://www.perlfoundation.org/artistic_license_2_0>
( run in 1.346 second using v1.01-cache-2.11-cpan-39bf76dae61 )