crane-flatten
Flatten a multi-platform container image
TLDR
Flatten an image
Apply new tag to flattened image
Display help
SYNOPSIS
crane flatten [-f
PARAMETERS
-f
Write the flattened image to a file instead of to the registry, allowing for direct disk access.
The name or reference of the container image to flatten. This can be a tag, digest, or fully qualified image name.
DESCRIPTION
The crane-flatten command flattens a container image by combining all layers into a single layer. This can be useful for optimizing image storage and distribution, particularly in environments where layer sharing is limited or inefficient. Flattening eliminates the layer structure, reducing the number of files required to store and transfer the image.
This process creates a new image with all the content present in the original image, but without the layer hierarchy. Because a single layer results in fewer files to be written when pulling an image it can improve the pull time of images. However, because layers are not shared, it can increase image size and storage requirements if used inappropriately.
crane-flatten typically operates by extracting the content of each layer and then assembling them into a single layer image. This command is part of the crane suite of container image management tools.
CAVEATS
Flattening an image removes layer sharing benefits. The resulting image may be larger than the original. Layer metadata and history are also lost in the process. It is only available when crane is installed.
USE CASES
Common use cases include optimizing images for environments with limited layer sharing capabilities, creating single-file images for specific deployment scenarios, and preparing images for archiving.
ALTERNATIVES
Alternative tools for flattening container images include docker export followed by docker import. However, crane-flatten is often preferred for its efficiency and specific focus on flattening within a container image management context.
HISTORY
crane and its associated commands, including crane-flatten, are relatively recent additions to the container ecosystem, primarily developed for improved container image management and optimization. It's designed to simplify operations like flattening, copying, and pushing images, offering an alternative to traditional tools like docker in specific scenarios. It is not included in most distributions but has to be installed separately.