import
proc.run:
podman: podman_cli
_container.dockman: dockman
pub let Image = dockman.Image
pub let Container = dockman.Container
pub let NoImageError = dockman.NoImageError
pub let NoContainerError = dockman.NoContainerError
pub let InvalidImageReferenceError = dockman.InvalidImageReferenceError
pub let RegistryAuthError = dockman.RegistryAuthError
pub let ArchiveError = dockman.ArchiveError
class PodmanRuntime: dockman.Runtime
def (init) self
dockman.Runtime.(init) $self :PODMAN:
pub def cli _self ...args
env LC_ALL: C LANG: C do
podman_cli ...args
let podman = PodmanRuntime()
# Run a verbatim command in a temporary Podman container from `image`.
#
# Returns `nil`.
pub def run image cmd ...args
podman.run $image $cmd ...args
# Run a function in a temporary Podman container from `image`.
#
# Program execution and filesystem access will be redirected for the
# duration of the function.
#
# # Returns
#
# The result of `func`
pub def with image func
podman.with $image $func
# Build a container image with `podman`
#
# ## Base parameters
#
# - `from`: base image
# - `pull`:
# - `:missing:` (default): only pull missing images
# - `:always:`: always attempt to pull images
# - `tag`: output image tag; may be omitted or repeated
#
# ## `mounts: <array>`
#
# Container mounts available for the entire build process.
# Each element is a `dict` of the form:
#
# - `type`:
# - `cache`: Mount a persistent cache at `target`
# - `bind`: Bind mount `source` at `target`
# - `target: <path | str>`: target mount path
# - `source: <path | str>`: mount source (omit for `cache` mounts)
# - `id` (optional): identifier for `cache` mounts; `target` used if omitted
#
# ## Build steps
#
# ### `run: func`
#
# Run `func` (a callable) inside the container
#
# ### `add: <dict>`
#
# A dictionary:
#
# - `source: <path | url | str>`: source path
# - `content: <str | bin>`: content to write directly to `target`
# - `target: <path | str>`: target path; if a directory, source file
# name will be appended for `source`, but not for `content`
# - `chmod: mode`: permissions
#
# ### `commit: msg`
#
# Creates a layer with the given message
#
# ## Example
# # Returns
#
# The final `Image`
#
# ```
# import podman
# let img = podman.build
# from: ubuntu:24.04
# run: do run apt install -y curl
# tag: my-image
# assert_eq $img.tags()[0].tag my-image
# ```
pub def build
:pull = :missing:
:mounts = []
:from ...args
do
podman.build :pull :mounts :from ...args
# List images, returning an iterator of `Image` objects
#
# # Parameters
#
# - `all:` show all images
# - `filter`: optional filter expression (e.g. `"reference=myapp*"`)
#
# # Returns
#
# An iterator of `Image` objects, one per repository:tag pair
pub def images :all = false :filter = nil
podman.images :all :filter
# Get a single image by reference
#
# # Parameters
#
# - `ref`: image reference (e.g. `"myapp:latest"`, `"sha256:abc..."`)
#
# # Returns
#
# An `Image` object
pub def image ref
podman.image $ref
# List containers.
pub def containers :all = false :filter = nil
podman.containers :all :filter
# Get a single container by ID or name.
pub def container ref
podman.container $ref
# Save one or more images to an archive or directory.
#
# `format:` accepts either strings such as `oci_archive` or symbols such as
# `:oci_archive:`.
pub def save target :format = :docker_archive: :platform = nil ...images
podman.save $target :format :platform ...images
# Load images from an archive.
pub def load source :platform = nil
podman.load $source :platform
# Pull an image from a registry.
pub def pull ref :platform = nil
podman.pull $ref :platform
# Push an image to a registry.
pub def push ref :platform = nil
podman.push $ref :platform