The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Docker::Client

SYNOPSIS

    use Docker::Client;

    my $client = Docker::Client->new();

    my $tx = $client->ContainerCreate(
        {},
        json => {
            Image        => 'ubuntu',
            AttachStdin  => 0,
            AttachStdout => 1,
            AttachStderr => 1,
            Tty          => 1,
            Cmd          => [ '/bin/bash', '-c', 'tail -f /etc/resolv.conf' ],
            OpenStdin    => 0,
            StdinOnce    => 0
        }
    );

    my $container = $ctx->result()->json();

    $tx = $client->ContainerStart( { id => $container->{Id} } );
    if ( !$tx->result()->is_success() ) {
        ...
    }

    $tx = $client->ContainerStop( { id => $container->{Id} } );
    if ( !$tx->result()->is_success() ) {
        ...
    }

DESCRIPTION

This module is built on top of OpenAPI::Client and the official OpenAPI specifications from docker.com. It supports multiple versions of Docker API, and in the local context, it doesn't require exposing the Docker API server on a TCP socket as it makes use of the "/var/run/docker.sock" file. Under the hood the all requests are handled by a Mojo::UserAgent instance, which is highly configurable.

This module is EXPERIMENTAL, the methods are subject to change. In the future I might hide all API calls under custom method implementations to resemble a high level API.

ATTRIBUTES

endpoint

The Docker REST endpoint. Defaults to 'http+unix://var/run/docker.sock'.

version

The Docker OpenAPI spec version. Defaults to 'v1.40', lower value supported is 'v1.25'.

ua

The Mojo::UserAgent object used to perform the requests.

METHODS

All methods are generated from the OpenAPI spec upon class instantiation and have the same name as the OperationId property.

MethodName

    my $tx = $client->MethodName( \%params, %content );

Returns a Mojo::HTTP::Transation object which contains the response with some additional features.

MethodName_p

Same as above, but returning a Mojo::Promise object.

For the latest version (1.40) the methods are:

  • ContainerList

  • ContainerCreate

  • ContainerInspect

  • ContainerTop

  • ContainerLogs

  • ContainerChanges

  • ContainerExport

  • ContainerStats

  • ContainerResize

  • ContainerStart

  • ContainerStop

  • ContainerRestart

  • ContainerKill

  • ContainerUpdate

  • ContainerRename

  • ContainerPause

  • ContainerUnpause

  • ContainerAttach

  • ContainerAttachWebsocket

  • ContainerWait

  • ContainerDelete

  • ContainerArchiveInfo

  • ContainerArchive

  • PutContainerArchive

  • ContainerPrune

  • ImageList

  • ImageBuild

  • BuildPrune

  • ImageCreate

  • ImageInspect

  • ImageHistory

  • ImagePush

  • ImageTag

  • ImageDelete

  • ImageSearch

  • ImagePrune

  • SystemAuth

  • SystemInfo

  • SystemVersion

  • SystemPing

  • SystemPingHead

  • ImageCommit

  • SystemEvents

  • SystemDataUsage

  • ImageGet

  • ImageGetAll

  • ImageLoad

  • ContainerExec

  • ExecStart

  • ExecResize

  • ExecInspect

  • VolumeList

  • VolumeCreate

  • VolumeInspect

  • VolumeDelete

  • VolumePrune

  • NetworkList

  • NetworkInspect

  • NetworkDelete

  • NetworkCreate

  • NetworkConnect

  • NetworkDisconnect

  • NetworkPrune

  • PluginList

  • GetPluginPrivileges

  • PluginPull

  • PluginInspect

  • PluginDelete

  • PluginEnable

  • PluginDisable

  • PluginUpgrade

  • PluginCreate

  • PluginPush

  • PluginSet

  • NodeList

  • NodeInspect

  • NodeDelete

  • NodeUpdate

  • SwarmInspect

  • SwarmInit

  • SwarmJoin

  • SwarmLeave

  • SwarmUpdate

  • SwarmUnlockkey

  • SwarmUnlock

  • ServiceList

  • ServiceCreate

  • ServiceInspect

  • ServiceDelete

  • ServiceUpdate

  • ServiceLogs

  • TaskList

  • TaskInspect

  • TaskLogs

  • SecretList

  • SecretCreate

  • SecretInspect

  • SecretDelete

  • SecretUpdate

  • ConfigList

  • ConfigCreate

  • ConfigInspect

  • ConfigDelete

  • ConfigUpdate

  • DistributionInspect

  • Session

AUTHOR

Tudor Marghidanu

COPYRIGHT AND LICENSE

Copyright (c) 2020, Tudor Marghidanu.

This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.