Container Image Compression via Block Device Mounting
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
The distribution of large container images in cloud environments is inefficient due to high image volumes, leading to slow distribution speeds and increased network resource pressure, as well as degraded user experience from network file system access delays.
Innovation Solution
A container image processing method that involves constructing a complete image, determining and deleting specified directories with high space occupation, compressing the image using the Docker Squash mechanism, and mounting the compressed image to a block device file system, thereby reducing image size and eliminating network access delays.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Volume of stationary object
If the image is mounted to a network file system to reduce image size, then the image size is reduced, but the user experience is degraded due to network transmission delay
Solution Approach 1:
The patent introduces a local disk as an intermediary between the container and the network file system. The image is first pulled and stored locally on the disk, then mounted to a local directory. This local disk intermediary eliminates network transmission delays for subsequent access while maintaining the ability to use network storage for the base image, thus resolving the contradiction between reducing image size and maintaining user experience.
2Volume of stationary object
If the image is split into multiple small images with sub-functions, then the size of a single image is reduced, but the overall image size is not reduced and maintenance costs increase
Solution Approach 1:
The patent segments the image access into two parts: the base image stored in the network file system and the locally cached image layers. This segmentation allows the system to maintain a single comprehensive image definition while only transferring and storing the necessary layers locally, reducing both single image size and maintenance complexity compared to splitting into multiple functional images.
3Speed
If the complete image is pulled to local disk, then the distribution speed is fast, but the network resource pressure is high when high concurrency occurs
Solution Approach 1:
The patent implements preliminary action by pre-pulling and caching image layers to the local disk before they are needed for container execution. The first-time pull operation stores layers locally, and subsequent container creations reuse these cached layers. This preliminary caching action reduces network resource pressure during high concurrency while maintaining fast distribution speed for subsequent operations.
Data Source
AI summary
Embodiments of the present disclosure provide a container image processing method and apparatus, and a storage medium. The method includes: obtaining required file information for generating a container image, and constructing a complete image according to the required file information; determining a specified directory to be deleted in the complete image, and compressing the complete image based on the specified directory to be deleted to obtain a compressed image; obtaining directory content of the specified directory to be deleted, and generating content to be mounted based on the directory content of the specified directory to be deleted; and storing the content to be mounted to a block device file system, and mounting the compressed image to the block device file system.


