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}")
This commit is contained in:
Thomas Woerner
2026-02-09 15:29:30 +01:00
parent 2f34e1ac6a
commit a24e90ad0c

View File

@@ -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"
}