Skip to content

Getty/p5-api-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API-Docker

CPAN Version License

Perl client for the Docker Engine API.

Installation

cpanm API::Docker

Or from source:

dzil build
dzil test
dzil install

Synopsis

use API::Docker;

# Connect to local Docker daemon via Unix socket
my $docker = API::Docker->new;

# Or connect to remote Docker daemon
my $docker = API::Docker->new(
    host => 'tcp://192.168.1.100:2375',
);

# System information
my $info = $docker->system->info;
my $version = $docker->system->version;

# Container management
my $containers = $docker->containers->list(all => 1);
my $result = $docker->containers->create(
    Image => 'nginx:latest',
    name  => 'my-nginx',
);
$docker->containers->start($result->{Id});

# Image operations
$docker->images->pull(fromImage => 'nginx', tag => 'latest');
my $images = $docker->images->list;

# Network and volume management
my $networks = $docker->networks->list;
my $volumes = $docker->volumes->list;

Description

API::Docker is a pure Perl client for the Docker Engine API. It provides a clean object-oriented interface to manage Docker containers, images, networks, and volumes without the overhead of heavy HTTP client libraries.

Key Features

  • Pure Perl implementation with minimal dependencies (no LWP)
  • Unix socket and TCP transport support
  • Automatic API version negotiation with Docker daemon
  • Object-oriented entity classes (Container, Image, Network, Volume)
  • HTTP/1.1 implementation with chunked transfer encoding
  • Comprehensive logging via Log::Any

Methods

new(%opts)

Create a new Docker client. Options:

  • host — connection URL, defaults to $ENV{DOCKER_HOST} or unix:///var/run/docker.sock
  • api_version — Docker API version (auto-negotiated if not set)
  • tls — enable TLS (experimental)
  • cert_path — path to TLS certs, defaults to $ENV{DOCKER_CERT_PATH}

system

Returns LAPI::Docker::API::System for system operations (info, version, ping, df, events).

containers

Returns LAPI::Docker::API::Containers for container management.

images

Returns LAPI::Docker::API::Images for image management.

networks

Returns LAPI::Docker::API::Networks for network management.

volumes

Returns LAPI::Docker::API::Volumes for volume management.

exec

Returns LAPI::Docker::API::Exec for executing commands in containers.

License

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages