A method and system for running a container image under a linux system with a non-functional kernel function

By acquiring image layers and information under Linux systems with incomplete kernel functionality, creating runtime directories, and mounting image layers, the problem of container images failing to start normally was solved, enabling container operation on more Linux systems and improving the scalability and performance of cloud-native applications.

CN115809116BActive Publication Date: 2026-03-24HANGZHOU HARMONYCLOUD TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-08
Publication Date
2026-03-24

AI Technical Summary

Technical Problem

Existing mainstream container runtimes cannot properly start container images on Linux systems with incomplete kernel functionality, hindering the expansion of cloud-native applications.

Method used

A method and system are provided to obtain user parameters, match and retrieve image layers and information from the database, create a container runtime directory, mount the image layer to the directory, start the container according to the startup information, and manage the working status of the container to ensure its normal operation.

Benefits of technology

It enables container images to run normally on Linux systems with incomplete kernel functionality, expands the scenarios for cloud-native applications, improves program disk performance, and avoids dependence on specific kernel functions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115809116B_ABST
    Figure CN115809116B_ABST
Patent Text Reader

Abstract

The application discloses a method for running a container image under a linux system with incomplete kernel functions, and belongs to the technical field of computers, and the method comprises the following steps: acquiring user parameters; according to the user parameters, matching and acquiring corresponding image layers and image information in a database; the image information comprises data mounting directories and startup information; according to the data mounting directories, creating a container running directory in the container; mounting the image layers into the container running directory to obtain mounted image layers; and starting the container according to the startup information and the mounted image layers. The application further discloses a system for running a container image under a linux system with incomplete kernel functions. The application can run the container image without relying on specific functions of the linux kernel.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a method and system for running container image under linux system with incomplete kernel functions. BACKGROUND

[0002] With the update and development of container technology, the application of container technology in Internet companies is becoming more and more widespread. More and more servers in companies use container technology, and more and more services choose to use container images for release. The most commonly used container runtime in actual production environment is Docker. When starting a container, Docker makes the following isolation and preparation for preparing the container environment:

[0003] 1. Container file system:

[0004] Download the image and decompress each layer, use different storagedriver, according to the image description file, mount the image layers to form the rootfs of the container;

[0005] 2. Network environment:

[0006] According to different container network schemes, configure the way of communication between the container environment namespace and the rootfs and the host, which varies from each other, to ensure that the container can communicate with the outside world;

[0007] 3. Namespace:

[0008] Docker uses MountNamespace, UTSNamespace, IPCNamespace, PIDNamespace, NetworkNamespace, UserNamespace, etc. to realize the isolation of the mount, host domain name, process communication, process number, network and user system of the container.

[0009] 4. Resource isolation:

[0010] Docker uses Cgroup to realize the limitation and isolation of the computing resources (cpu, memory, IO) of a single container;

[0011] Subsequently, the container runtime starts the container according to the image description file and runtime parameters on this basis.

[0012] Mainstream container runtime such as Docker runs in data center, uses the isolation technologies in the container runtime above, and improves the resource utilization of the data center. At the same time, the implementation of the above isolation technologies needs to rely on the functions provided by the host system kernel. With the deepening of the process of enterprise cloud native transformation, more and more software will be delivered in the form of container images, and the running container scenarios will also be expanded from data centers to more daily life scenarios, and the hardware will also be expanded from ordinary servers to personal computers, personal computing terminals, Internet of Things devices, etc. A large part of the linux kernel in the newly expanded computing device is tailored and customized on demand, which makes the ordinary container runtime unable to start the container in the normal way. Therefore, the existing mainstream container runtime cannot adapt to the expanded container running scenarios, which hinders the overall cloud native of enterprises. SUMMARY

[0013] The purpose of the present application is to provide a method and system for running a container image in a linux system with incomplete kernel functions, which does not rely on specific functions of the linux kernel to run the container image.

[0014] To solve the above technical problems, the present application provides a method for running a container image in a linux system with incomplete kernel functions, comprising the following steps:

[0015] Obtain user parameters;

[0016] According to the user parameters, match and obtain the corresponding image layer and image information in the database; the image information includes data mounting directory and startup information;

[0017] According to the data mounting directory, create a container running directory in the container;

[0018] Mount the image layer into the container running directory to obtain the mounted image layer;

[0019] According to the startup information and the mounted image layer, start the container.

[0020] Preferably, the method further comprises the following steps:

[0021] Obtain the working state of the container;

[0022] According to the working state of the container, manage the container.

[0023] Preferably, the working state of the container includes the current running state and the desired state.

[0024] Preferably, according to the working state of the container, the container is managed, specifically comprising the following steps:

[0025] If the desired state is running and the current running state is non-running, the working state of the container is abnormal, and the container is restarted.

[0026] If the desired state is running and the current running state is running, it is checked whether the corresponding pid process is alive; if the pid process is not alive, the working state of the container is abnormal, and the container is restarted;

[0027] If the desired state is stop and the current running state is running, the working state of the container is shutdown, and the container is closed.

[0028] Preferably, the startup information includes environment variables, startup commands and startup parameters.

[0029] The application also provides a system for running a container image under a linux system with incomplete kernel functions, comprising:

[0030] An acquisition module is configured to acquire user parameters;

[0031] A matching module is configured to match and acquire corresponding image layers and image information in a database according to the user parameters; the image information includes data mounting directories and startup information;

[0032] A creation module is configured to create a container running directory in the container according to the data mounting directories;

[0033] A mounting module is configured to mount the image layers into the container running directory to obtain mounted image layers;

[0034] A startup module is configured to start the container according to the startup information and the mounted image layers.

[0035] Compared with the prior art, the application has the following beneficial effects:

[0036] The application can run standard container images in more linux variant systems, expand the cloud-native application field, run container images without relying on specific functions of the linux kernel, and cannot start the traditional container runtime; the program disk performance is comparable to that of the native system without using the stacked file system. BRIEF DESCRIPTION OF DRAWINGS

[0037] The specific embodiments of the application will be further described in detail below with reference to the accompanying drawings.

[0038] Figure 1 is a flowchart of a method for running a container image under a linux system with incomplete kernel functions;

[0039] Figure 2 is a schematic diagram of mounting an image layer into a container. DETAILED DESCRIPTION

[0040] Numerous specific details are set forth in the following description to provide a full understanding of the invention. However, the invention can be practiced in many other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.

[0041] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of this specification. The singular forms “a,” “described,” and “the” as used in one or more embodiments of this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.

[0042] It should be understood that although the terms first, second, etc., may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this specification, and similarly, second may also be referred to as first. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."

[0043] The following is in conjunction with the appendix Figures 1-2 The present invention will be described in further detail as follows:

[0044] This invention attempts to solve the problem of container images not being able to run on a trimmed Linux kernel system. This requires trimming runtime functionality according to actual needs and addressing the omission of some key features. It also aims to extend containers and cloud-native technologies to more scenarios.

[0045] like Figure 1 As shown, this invention provides a method for running a container image on a Linux system with an incomplete kernel, comprising the following steps:

[0046] Get user parameters;

[0047] Based on user parameters, the corresponding image layer and image information in the database are matched and obtained; the image information includes the data mount directory and startup information.

[0048] Based on the data mount directory, create the container runtime directory within the container;

[0049] Mount the image layer to the container's runtime directory to obtain the mounted image layer;

[0050] According to the start information and the mounted image layer, the container is started.

[0051] The preferred embodiment further comprises the following steps:

[0052] Obtaining the working state of the container;

[0053] According to the working state of the container, the container is managed.

[0054] The preferred embodiment, the working state of the container comprises a current running state and an expected state.

[0055] The preferred embodiment, according to the working state of the container, the container is managed, specifically comprising the following steps:

[0056] If the expected state is running and the current running state is non-running, the working state of the container is abnormal, and the container is restarted;

[0057] If the expected state is running and the current running state is running, it is checked whether the corresponding pid process is alive; if the pid process is not alive, the working state of the container is abnormal, and the container is restarted;

[0058] If the expected state is stopped and the current running state is running, the working state of the container is to be shut down, and the container is closed.

[0059] The preferred embodiment, the start information comprises environment variables, start commands and start parameters.

[0060] The application also provides a system for running a container image in a linux system with incomplete kernel functions, comprising:

[0061] The obtaining module is used for obtaining user parameters;

[0062] The matching module is used for matching and obtaining corresponding image layers and image information in the database according to the user parameters; the image information comprises data mounting directories and start information;

[0063] The creating module is used for creating a container running directory in the container according to the data mounting directories;

[0064] The mounting module is used for mounting the image layers into the container running directory to obtain mounted image layers;

[0065] The starting module is used for starting the container according to the start information and the mounted image layers.

[0066] The application is used as a substitute for a traditional container runtime, and mainly relates to two functional modules of image storage and container running.

[0067] Regarding image storage, this invention follows the standards in the OCI Distribution Specification to download images from the image repository and store them in compressed packages in the host system's default file system, organized by image layer. Image description files are maintained separately, pointing to each image layer. Image information is stored locally and associated with the image description files. If multiple images depend on the same image layer, there is no need to download them repeatedly.

[0068] The operation of container images is divided into four stages: context configuration, file system preparation, startup, and daemonization.

[0069] 1. Context configuration:

[0070] Based on user parameters, retrieve image layers from the image repository, retrieve image information from the local machine, create container directories based on the image information, and retrieve image description files, which include container status description files and container runtime description files.

[0071] The container state description file includes state information such as expected state, current running state, process ID, etc.

[0072] The container runtime description file is based on the image description file and combines it with the parameters passed by the user. It is a combination of the prerequisites that need to be prepared before the container can run, including environment variables, data mount directories, startup commands, startup parameters, etc.

[0073] 2. File system preparation:

[0074] Based on the mount directories in the container runtime description file, extract the image layers sequentially to the corresponding folders within the container, such as... Figure 2 As shown;

[0075] Based on the data in the container runtime description file, the host system's corresponding directories (currently / proc and / dev) are bound and mounted to the container's corresponding file directories using the bindmount method.

[0076] 3. Startup:

[0077] Switch the container's running directory to the root directory of the image layer within the corresponding container;

[0078] Based on the container runtime description file, set the context (environment variables) required to run the container application;

[0079] Run the startup command and startup parameters according to the container runtime description file;

[0080] Update the running status and process ID in the container status description file.

[0081] 4. Guardian:

[0082] Check the state corresponding to the state description file of each container at a fixed frequency;

[0083] If the desired state is running and the current running state is not running, go to step 3;

[0084] If the desired state is running and the current running state is running, check whether the corresponding pid process is alive, and if not, go to step 3;

[0085] If the desired state is stop and the current running state is running, send a stop signal to the corresponding process and close the container.

[0086] The desired state is issued by the user (similar to docker start and docker stop), and is recorded.

[0087] In order to better illustrate the technical effects of the present application, the following specific examples are provided to illustrate the above technical process:

[0088] 1. Running a standard tomcat image in a 32-bit android system:

[0089] This experiment uses motorola XT1068, which uses Qualcomm MSM8226, is a 4-core Cortex-A7 architecture, and is a 32-bit processor with 1G memory. The operating system is a 3.4.113 version of the kernel of the android 7.1 after being trimmed. After obtaining the root permission, we set the runtime image directory and the running directory in the / data directory, and start the service in the directory, pull the public tomcat image, and start it. At the same time, the service is successfully accessed on the local machine.

[0090] 2. Running a standard container image in a 64-bit debian system based on the android kernel:

[0091] This experiment uses a development version based on rockchip rk3399 chip. It uses a big core design dual-core A72+ quad-core A53 with 4G memory. We successfully start the runtime service in the system and pull the image to start the service.

[0092] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules, modules or units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units, modules or components can be combined or integrated into another device, or some features can be ignored or not executed.

[0093] The units can or can not be physically separate, and the components displayed as units can be one physical unit or multiple physical units, i.e., can be located in one place, or can also be distributed to multiple different places. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment of the present application.

[0094] In addition, each functional unit in various embodiments of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.

[0095] In particular, according to the embodiments disclosed in the present application, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, the embodiments of the present application include a computer program product comprising a computer program carried on a computer readable medium, the computer program comprising program code for executing the method shown in the flowchart. In such embodiments, the computer program can be downloaded and installed from a network by a communication part, and / or installed from a detachable medium. When the computer program is executed by a central processing unit (CPU), the above-mentioned functions defined in the method of the present application are executed. It should be noted that the above-mentioned computer readable medium of the present application can be a computer readable signal medium or a computer readable storage medium or any combination of the two. The computer readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared ray segment, or semiconductor system, device or apparatus, or any combination of the above.

[0096] The flowcharts and block diagrams in the drawings illustrate the possible implementation architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each block in the flowchart or block diagram can represent a module, a program segment, or a part of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur in different orders than those noted in the drawings. For example, two blocks indicated in succession can actually be executed substantially in parallel, and sometimes they can be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, can be realized by a dedicated hardware-based system that performs the specified function or operation, or can be realized by a combination of dedicated hardware and computer instructions.

[0097] The above merely illustrates the specific embodiments of the present application, but the protection scope of the present application is not limited thereto, any change or replacement within the technical scope disclosed by the present application should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A method for running a container image on a Linux system with an incomplete kernel, characterized in that, Includes the following steps: Get user parameters; Based on user parameters, the corresponding image layer and image information in the database are matched and obtained; the image information includes the data mount directory and startup information. Based on the data mount directory, create the container runtime directory within the container; Mount the image layer to the container's runtime directory to obtain the mounted image layer; Start the container based on the startup information and the mounted image layer; Obtain the working status of the container; the working status of the container includes the current running status and the desired status. If the expected state is running, but the current running state is not running, then the container's working state is abnormal, and the container should be restarted. If the expected state is running, and the current running state is running, then check if the corresponding PID process is alive; if the PID process is not alive, the container's working state is abnormal, and the container is restarted. If the desired state is stopped and the current running state is running, then the container's working state is pending shutdown, and the container is shut down.

2. The method for running a container image under a Linux system with incomplete kernel functionality according to claim 1, characterized in that: The startup information includes environment variables, startup commands, and startup parameters.

3. A system for running container images under a Linux system with an incomplete kernel, used to implement the method for running container images under a Linux system with an incomplete kernel as described in any one of claims 1-2, characterized in that, include: The acquisition module is used to acquire user parameters; The matching module is used to match and retrieve the corresponding image layer and image information from the database based on user parameters; The image information includes the data mount directory and startup information; Create a module to create the container runtime directory within the container based on the data mount directory; The mount module is used to mount the image layer to the container's runtime directory, thus obtaining the mounted image layer; The startup module is used to start the container based on the startup information and the mounted image layer.

Citation Information

Patent Citations

  • Starting acceleration method and system for large-scale cluster container with mixed CPU (central processing unit) framework

    CN114416296A