From f45b668c97806cf5e39ecc5d8dcda048541f6359 Mon Sep 17 00:00:00 2001 From: nkraetzschmar <9020053+nkraetzschmar@users.noreply.github.com> Date: Mon, 2 Dec 2024 10:40:49 +0100 Subject: [PATCH 1/3] doc: direct container image usage --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8ee68d9..3a0ef71 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ The **unbase OCI tool** is designed to streamline container images by eliminating unnecessary components inherited from the base container, thereby reducing bloat and enhancing security. It produces [bare container images](https://github.com/gardenlinux/gardenlinux/blob/main/docs/01_developers/bare_container.md). -Operating on OCI archives, the tool performs a thorough comparison between a base image and a target image. +Operating on OCI archives or container images, the tool performs a thorough comparison between a base image and a target image. It identifies additions made to the target image in relation to the base image, as well as the dependencies of these additions. The tool then strips away extraneous elements, resulting in a minimized target image. @@ -29,6 +29,17 @@ chmod +x unbase_oci ``` ./unbase_oci [options] base_image target_image output_image +base_image, target_image, and output_image can either be OCI-archive file names +or container images of the form "${container_engine}:${image}". +For this the images must already be pulled in the local image storage of ${container_engine}. + +For all but base_image you can use the ":${tag}" shorthand to indicate that the same container engine +and image name as the previous arg should be used, but with a different tag. + +If target_image is not using the shorthand notation, then base_image can be set to "auto". +This will automatically resolve the base_image based on meta-data in the target_image. +Note: this only works for images locally build via a Containerfile/Dockerfile. + Options: -i, --include INCLUDE_FILE Specify regex patterns to selectively include files. Patterns are in grep extended regex format (one per line). From fde777adcdaa9cf5e6c4e8dae5675205ba7d040e Mon Sep 17 00:00:00 2001 From: Florian Wilhelm Date: Mon, 2 Dec 2024 11:03:46 +0100 Subject: [PATCH 2/3] add usage example --- README.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3a0ef71..85f29e5 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,8 @@ chmod +x unbase_oci ./unbase_oci [options] base_image target_image output_image base_image, target_image, and output_image can either be OCI-archive file names -or container images of the form "${container_engine}:${image}". +or container images of the form "${container_engine}:${image}" where ${container_engine} +might be `podman` or `docker`. For this the images must already be pulled in the local image storage of ${container_engine}. For all but base_image you can use the ":${tag}" shorthand to indicate that the same container engine @@ -68,7 +69,19 @@ Options: ## Example Usage -For instance, consider building a container on top of a Debian base. Let's assume `debian.oci` represents an exported OCI archive of the Debian base image, while `container.oci` is an exported OCI archive of the target image. To create a *bare* variant of the target container, containing only the dependencies of explicitly installed components on top of Debian (e.g.: libc), execute: +For instance, consider building a container on top of a Debian base. +Let's assume you build your container with a `Containerfile` based on the `debian` image. +To create a *bare* variant of the target container, containing only the dependencies of explicitly installed components on top of Debian (e.g.: libc), execute: + +```shell +podman pull debian +podman build -t container . +./unbase_oci --ldd-dependencies podman:debian podman:container:latest podman:container:bare +``` + +After running this command, the image `container:bare` is available in your local podman instance. + +If you work with exported oci archives, the equivalent command is: ```shell ./unbase_oci --ldd-dependencies debian.oci container.oci container_bare.oci From bbb0d1ce11bee890ddcaca13d180c0ebbf8fb1e8 Mon Sep 17 00:00:00 2001 From: Florian Wilhelm Date: Mon, 2 Dec 2024 11:21:14 +0100 Subject: [PATCH 3/3] [no ci] fix --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 85f29e5..173a7a6 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,9 @@ chmod +x unbase_oci base_image, target_image, and output_image can either be OCI-archive file names or container images of the form "${container_engine}:${image}" where ${container_engine} -might be `podman` or `docker`. +is `podman`. For this the images must already be pulled in the local image storage of ${container_engine}. +See the usage example below. For all but base_image you can use the ":${tag}" shorthand to indicate that the same container engine and image name as the previous arg should be used, but with a different tag.