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.
Reference to WWW::Docker client. Weak reference to avoid circular dependencies.
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 informationfilters- Hashref of filters
# 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 outputnocache- Do not use cache when buildingpull- Always pull base imagerm- Remove intermediate containers (default: true)forcerm- Always remove intermediate containersbuildargs- HashRef of build-time variableslabels- HashRef of labels to set on the imagememory- Memory limit in bytesmemswap- Total memory (memory + swap), -1 to disable swapcpushares- 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 bytesnetworkmode- Network mode during buildplatform- Platform (e.g.linux/amd64)target- Multi-stage build target
$images->pull(fromImage => 'nginx', tag => 'latest');
Pull an image from a registry. tag defaults to latest.
my $image = $images->inspect('nginx:latest');
Get detailed information about an image. Returns WWW::Docker::Image object.
my $history = $images->history('nginx:latest');
Get image history (layers). Returns ArrayRef of layer information.
$images->push('myrepo/nginx', tag => 'v1');
Push an image to a registry. Optionally specify tag.
$images->tag('nginx:latest', repo => 'myrepo/nginx', tag => 'v1');
Tag an image with a new repository and/or tag name.
$images->remove('nginx:latest', force => 1);
Remove an image.
Options:
force- Force removalnoprune- 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.
my $result = $images->prune(filters => { dangling => ['true'] });
Delete unused images. Returns hashref with ImagesDeleted and SpaceReclaimed.
WWW::Docker - Main Docker client
WWW::Docker::Image - Image entity class
12 POD Errors
The following errors were encountered while parsing the POD:
- Around line 57:
Unknown directive: =attr
- Around line 86:
Unknown directive: =method
- Around line 148:
Unknown directive: =method
- Around line 228:
Unknown directive: =method
- Around line 243:
Unknown directive: =method
- Around line 257:
Unknown directive: =method
- Around line 273:
Unknown directive: =method
- Around line 290:
Unknown directive: =method
- Around line 307:
Unknown directive: =method
- Around line 335:
Unknown directive: =method
- Around line 352:
Unknown directive: =method
- Around line 360:
Unknown directive: =seealso