Container-Builder
view release on metacpan or search on metacpan
enable_packages_cache will look for a Packages file defined by
packages_file option. If it doesn't exist, it will be downloaded from
the Debian mirror. If it does exist, it will be read from disk
instead of getting a fresh copy.
add_deb_package('libperl5.36')
Add a Debian package to the container. The data.tar file inside the
Debian package file (.deb) will be stored as a layer in the resulting
container.
add_deb_package_from_file($filepath_deb)
Add a Debian package file to the container. The data.tar file inside
the Debian package file (.deb) will be stored as a layer in the
resulting container.
extract_from_deb($package_name, $files_to_extract)
Extract certain files from the Debian package before storing as a
layer. $package_name is the name of the Debian package,
$files_to_extract is an array ref containing a list of files to
extract. Rudimentary support for globs/wildcards (only useable at the
end of the string).
This is an experimental method.
add_file($file_on_disk, $location_in_ctr, $mode, $user, $group)
Adds the local file $file_on_disk inside the container at location
$location_in_ctr with the specified $mode, $user and $group.
add_file_from_string($data, $location_in_ctr, $mode, $user, $group,
[$compressed])
Adds the data in the scalar $data to the container at location
$location_in_ctr with the specified $mode, $user and $group.
$compressed is a boolean to determine if the image layer will be
compressed.
copy($local_dirpath, $location_in_ctr, $mode, $user, $group)
Recursively copy the $local_dirpath directory into a layer of the
container. The resulting path inside the container is defined by
$location_in_ctr. $mode controls the directory permission of
$location_in_ctr only. Inner directories will have the permissions as
on the local filesystem. All directories and files will be changed to
be owned by $user and $group.
If $location_in_ctr has a slash at the end, the last directory of
$local_dirpath will become a subdirectory of the path
$location_in_ctr. Otherwise, the last directory of $local_dirpath
will be renamed to the last directory of $location_in_ctr.
For example copy('lib/', '/app/') will create /app/lib/ but
copy('lib/', '/app') will put all put the files and directories
directly inside /app, there will be no lib directory.
create_directory($path, $mode, $uid, $gid)
Create an empty directory at $path inside the container with the
specified $mode, $user and $group.
add_user($name, $uid, $main_gid, $shell, $homedir)
Add a user to the container. This puts the user inside the
/etc/passwd file.
add_group($name, $gid)
Add a group to the container. This puts the group inside the
/etc/group file.
runas_user($user)
Specify the user to run the entrypoint as.
set_env($key, $value)
Add a environment variable to the container definition.
set_entry(@command_str)
Set the default entrypoint of the container.
set_work_dir($workdirectory)
Set the default working directory of the container.
build()
build('mycontainer.tar')
build(filename_result => 'mycontainer.tar')
build('mycontainer.tar', 'localhost/ctr:latest')
build(filename_result => 'mycontainer.tar', tag_name =>
'localhost/ctr:latest')
Build the container and write the result to the filepath specified.
tag_name sets an annotation in the Index so that other tooling knows
how to tag the image container upon loading.
get_digest()
Returns the digest of the embedded config file in the archive. This
digest is used by tools such as podman as a unique ID to your
container.
get_layers()
Returns a list of Container::Builder::Layer objects as currently
added to the Builder.
Note: During build() extra layers can be added in the front or at the
end of this list.
AUTHOR
Adriaan Dens <adri@cpan.org>
COPYRIGHT
Copyright 2026- Adriaan Dens
LICENSE
This library is free software; you can redistribute it and/or modify it
( run in 0.863 second using v1.01-cache-2.11-cpan-97f6503c9c8 )