Linux command
crane-flatten 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Flatten an image and push it under a new tag
crane flatten [image] -t [flattened:tag]
Flatten by digest
crane flatten [image@sha256:...]
Flatten a specific platform
crane flatten [image] --platform linux/amd64 -t [flattened:tag]
说明
crane flatten squashes all layers of a container image into a single layer. This can reduce image size and improve pull times by eliminating layer overhead. The command reads the source image from the registry, builds a new manifest whose filesystem is the merged result of all layers, and pushes the new manifest back.
参数
- -t, --tag _tag_
- Tag to apply to the flattened image. If omitted, the result is pushed by digest to the same repository and the original tag is not overwritten.
- --platform _os/arch_
- Select a single platform when flattening a multi-arch image (e.g. linux/amd64).
- --insecure
- Allow connections to registries without valid TLS certificates.
- -v, --verbose
- Enable verbose logging.
FAQ
What is the crane-flatten command used for?
crane flatten squashes all layers of a container image into a single layer. This can reduce image size and improve pull times by eliminating layer overhead. The command reads the source image from the registry, builds a new manifest whose filesystem is the merged result of all layers, and pushes the new manifest back.
How do I run a basic crane-flatten example?
Run `crane flatten [image] -t [flattened:tag]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -t, --tag _tag_ do in crane-flatten?
Tag to apply to the flattened image. If omitted, the result is pushed by digest to the same repository and the original tag is not overwritten.