From a24e90ad0ca4c5528c0ce5e3d9ee8a66da18e34c Mon Sep 17 00:00:00 2001 From: Thomas Woerner Date: Mon, 9 Feb 2026 15:29:30 +0100 Subject: [PATCH] infra/image/shcontainer: New container_save and container_load The new container_save and container_load functions can be used to save and load container images. container_save Save a container image to a local file. Example: container_save "${name}" container_load Load a container image from an tar archive. Example: local_image=$(container_load "${archive}") --- infra/image/shcontainer | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/infra/image/shcontainer b/infra/image/shcontainer index 063b2720..517ab212 100644 --- a/infra/image/shcontainer +++ b/infra/image/shcontainer @@ -228,3 +228,22 @@ container_tee() { rm "${tmpfile}" echo } + +container_save() { + local name=${1} + + archive="${name}.tar" + log info "= Saving ${name} to ${archive} =" + # podman is not able to overwrite the archive + [ -f "${archive}" ] && rm "${archive}" + podman save -o "${archive}" "${name}" + echo +} + +container_load() { + local name=${1} + + image_name=$(podman load -q -i "${name}" | sed -e "s/^Loaded image: //") + image=$(podman image list -q "${image_name}") + echo "$image" +}