NAME

WWW::Docker::API::Images - Docker Engine Images API

VERSION

version 0.100

SYNOPSIS

my $docker = WWW::Docker->new;

# Build an image from a tar context
use Path::Tiny;
my $tar = path('context.tar')->slurp_raw;
$docker->images->build(context => $tar, t => 'myapp:latest');

# Pull an image
$docker->images->pull(fromImage => 'nginx', tag => 'latest');

# List images
my $images = $docker->images->list;
for my $image (@$images) {
    say $image->Id;
    say join ', ', @{$image->RepoTags};
}

# Inspect image details
my $image = $docker->images->inspect('nginx:latest');

# Tag and push
$docker->images->tag('nginx:latest', repo => 'myrepo/nginx', tag => 'v1');
$docker->images->push('myrepo/nginx', tag => 'v1');

# Remove image
$docker->images->remove('nginx:latest', force => 1);

DESCRIPTION

This module provides methods for managing Docker images including pulling, listing, tagging, pushing to registries, and removal.

All list and inspect methods return WWW::Docker::Image objects.

Accessed via $docker->images.

client

Reference to WWW::Docker client. Weak reference to avoid circular dependencies.

list

my $images = $images->list(all => 1);

List images. Returns ArrayRef of WWW::Docker::Image objects.

Options:

  • all - Show all images (default hides intermediate images)

  • digests - Include digest information

  • filters - Hashref of filters

build

# Build from a tar archive
my $tar_data = path('context.tar')->slurp_raw;
my $result = $docker->images->build(
    context    => $tar_data,
    t          => 'myimage:latest',
    dockerfile => 'Dockerfile',
);

# Build with build args
my $result = $docker->images->build(
    context   => $tar_data,
    t         => 'myapp:v1',
    buildargs => { APP_VERSION => '1.0' },
    nocache   => 1,
);

Build an image from a tar archive containing a Dockerfile and build context.

The context parameter is required and must contain the raw bytes of a tar archive (or a scalar reference to one).

Options:

  • context - Tar archive bytes (required)

  • dockerfile - Path to Dockerfile within the archive (default: Dockerfile)

  • t - Tag for the image (e.g. name:tag)

  • q - Suppress verbose build output

  • nocache - Do not use cache when building

  • pull - Always pull base image

  • rm - Remove intermediate containers (default: true)

  • forcerm - Always remove intermediate containers

  • buildargs - HashRef of build-time variables

  • labels - HashRef of labels to set on the image

  • memory - Memory limit in bytes

  • memswap - Total memory (memory + swap), -1 to disable swap

  • cpushares - CPU shares (relative weight)

  • cpusetcpus - CPUs to use (e.g. 0-3, 0,1)

  • cpuperiod - CPU CFS period (microseconds)

  • cpuquota - CPU CFS quota (microseconds)

  • shmsize - Size of /dev/shm in bytes

  • networkmode - Network mode during build

  • platform - Platform (e.g. linux/amd64)

  • target - Multi-stage build target

pull

$images->pull(fromImage => 'nginx', tag => 'latest');

Pull an image from a registry. tag defaults to latest.

inspect

my $image = $images->inspect('nginx:latest');

Get detailed information about an image. Returns WWW::Docker::Image object.

history

my $history = $images->history('nginx:latest');

Get image history (layers). Returns ArrayRef of layer information.

push

$images->push('myrepo/nginx', tag => 'v1');

Push an image to a registry. Optionally specify tag.

tag

$images->tag('nginx:latest', repo => 'myrepo/nginx', tag => 'v1');

Tag an image with a new repository and/or tag name.

remove

$images->remove('nginx:latest', force => 1);

Remove an image.

Options:

  • force - Force removal

  • noprune - Do not delete untagged parents

my $results = $images->search('nginx', limit => 25);

Search Docker Hub for images. Returns ArrayRef of search results.

Options: limit, filters.

prune

my $result = $images->prune(filters => { dangling => ['true'] });

Delete unused images. Returns hashref with ImagesDeleted and SpaceReclaimed.

SEE ALSO

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-www-docker/issues.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2025 by Torsten Raudssus.

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