WO2021164367A1 - 一种容器镜像的提供方法、加载方法及相关设备和系统 - Google Patents
一种容器镜像的提供方法、加载方法及相关设备和系统 Download PDFInfo
- Publication number
- WO2021164367A1 WO2021164367A1 PCT/CN2020/132681 CN2020132681W WO2021164367A1 WO 2021164367 A1 WO2021164367 A1 WO 2021164367A1 CN 2020132681 W CN2020132681 W CN 2020132681W WO 2021164367 A1 WO2021164367 A1 WO 2021164367A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- container image
- container
- path information
- resource
- entry point
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/43—Checking; Contextual analysis
- G06F8/436—Semantic checking
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
- G06F2009/45562—Creating, deleting, cloning virtual machine instances
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
- G06F2009/45575—Starting, stopping, suspending or resuming virtual machine instances
Definitions
- One or more embodiments of this specification relate to the technical field of computer technology, and in particular to a method for providing container images, a method for loading, and related equipment and systems.
- Container technology is a lightweight virtualization technology. When deploying a container in a node, you first need to download the container image of the container to the container.
- Container mirroring refers to various data files required when deploying a container, including content such as operating systems, software environments, and applications.
- the purpose of one or more embodiments of this specification is to provide a method for providing container images, a method for loading, and related equipment and systems.
- one or more embodiments of this specification provide a method for providing container images, including: obtaining and parsing a Dockerfile file of the container image to obtain entry point instructions in the Dockerfile; Perform semantic analysis to determine the resources required for the operation of the application in the container image; determine the path information of the resource, and generate a pre-reading list corresponding to the container image according to the path information; wherein, the pre-reading list The read list is configured to be downloaded together with the container image in response to a download request for the container image.
- one or more embodiments of this specification also provide a method for loading a container image, including: sending a download request of the container image, obtaining the container image and its corresponding pre-reading list; The event of the container image, read the pre-reading list, and determine the path information of the resources required for the operation of the application in the container image; according to the path information, load the application required for the operation of the container image H.
- one or more embodiments of this specification also provide a container image providing device, including: a parsing module configured to obtain and parse the Dockerfile file of the container image to obtain the entry point in the Dockerfile file Instruction; the determination module is configured to perform semantic analysis on the entry point instruction to determine the resources required for the operation of the application in the container image; the generation module is configured to determine the path information of the resource, and according to the The path information generates a pre-reading list corresponding to the container image; wherein the pre-reading list is configured to be downloaded together with the container image in response to a download request for the container image.
- a parsing module configured to obtain and parse the Dockerfile file of the container image to obtain the entry point in the Dockerfile file Instruction
- the determination module is configured to perform semantic analysis on the entry point instruction to determine the resources required for the operation of the application in the container image
- the generation module is configured to determine the path information of the resource, and according to the The path information generates a pre-reading list corresponding to the container image;
- one or more embodiments of this specification also provide a container image loading device, including: an acquisition module configured to send a download request of the container image, and obtain the container image and its corresponding pre-reading A list; a reading module configured to read the pre-reading list in response to the event of loading the container image, and determine the path information of the resources required for the operation of the application in the container image; the loading module is configured In order to load the resources required for the operation of the application program in the container image according to the path information.
- one or more embodiments of this specification also provide an electronic device, including a memory, a processor, and a computer program stored in the memory and running on the processor, and the processor executes the program When realizing the container image provision method described in any one of the above, or the container image loading method described in any one of the above.
- one or more embodiments of this specification also provide a container mirroring system, including: the container mirroring provision device as described in any one of the above; and the container mirroring loading as described in any one of the above Device.
- one or more embodiments of this specification provide container image providing methods, loading methods, and related equipment and systems.
- semantic analysis is used to determine the entry point in the Dockerfile of the container image.
- the resource required by the application running in the container image recorded in the instruction, and the path information of the resource is generated into a pre-reading list; the pre-reading list can be downloaded together with the container image when the container image is requested, and the container image is loaded At the time, the pre-reading list is read to load the resources required for the operation of the application, so that the container image is deployed as the container to run, which can realize the rapid startup of the application, thereby improving the quality and efficiency of the container operation.
- Figure 1 is a schematic diagram of an implementation scenario in related technologies
- Figure 2 is a schematic diagram of an implementation scenario of one or more embodiments of this specification.
- FIG. 3 is a flowchart of a method for providing a container image according to one or more embodiments of this specification
- FIG. 4 is a flowchart of the steps of determining the resources required for the operation of the application in the container image in one or more embodiments of the specification;
- FIG. 5 is a flowchart of a container image loading method according to one or more embodiments of this specification.
- FIG. 6 is a schematic structural diagram of a container image providing device according to one or more embodiments of this specification.
- FIG. 7 is a schematic structural diagram of a container image loading device according to one or more embodiments of this specification.
- FIG. 8 is a schematic structural diagram of an electronic device according to one or more embodiments of this specification.
- the container is created and generated based on the container image.
- a container can be understood as an example of a container image, which allows users to package applications and program dependencies into a portable container, and then deploy to a Linux device that supports the container (common Linux distributions basically support it). At the same time, process-level virtualization is realized.
- the container image is the basis for building the container, which is a hierarchical file system.
- a read-only layer is called a container image, and a container image is permanent. Because the container technology uses a unified file system, it is considered that the entire file system is mounted in a read-write mode. But all changes occur in the top writable layer, while the original read-only image file in the lower layer has not changed.
- the container image provides a read-only layer
- the read-write layer is added to the read-only layer to form a container, that is, the container image is deployed as a container on the device.
- the container image center is configured to store container images and provide container image sum and download services to execution devices.
- the execution device is a device used to deploy the container, which can be a physical device (for example, a server) or a virtual device (for example, a virtual machine).
- the execution device can request its stored container image from the container mirror center, and then download the container image from the container mirror center, and the downloaded container image can be deployed on the execution device as a container for operation.
- the execution device downloads and obtains the container image from the container image center, it is deployed as a container operation.
- the resources required for the application to run will be loaded. This method of loading resources when the application is accessed causes a slow startup speed of the application in the container, which affects the quality and efficiency of the container operation.
- One or more embodiments of this specification provide a method for providing container images, a loading method, and related equipment and systems.
- semantic analysis is used to determine the entry point instructions in the container image’s Dockerfile file.
- the resources required by the application to run, and the path information of the resources generates a pre-reading list; the pre-reading list can be downloaded together with the container image when the container image is requested, and the pre-reading list can be read when the container image is loaded
- the list is used to load the resources required for the application to run; that is, the resources are no longer loaded when the application is accessed, but when the container image is deployed as a container to run, the resources required for the application to run are loaded This effectively speeds up the startup speed of the application when the container is running, thereby improving the quality and efficiency of the container operation.
- One or more embodiments of this specification provide a method for providing a container image.
- the method for providing a container image includes steps S301 to S303.
- Step S301 Obtain and parse the Dockerfile file of the container image to obtain the entry point instruction in the Dockerfile file.
- Dockerfile is a script composed of a series of commands and parameters. These commands are applied to the basic container image and finally create a new container image. They simplify the process from beginning to end and greatly simplify the deployment. Dockerfile starts with the FROM instruction, followed by various methods, instructions and parameters, and the output is a new container image that can be used to create a container.
- the Dockerfile file is parsed to obtain the content code of the Dockerfile file, that is, several instructions that constitute the Dockerfile file.
- the following is an example of the content code of a Dockerfile file:
- entry point instruction In the content code of the above Dockerfile file, "ENTRYPOINT" is the entry point instruction.
- the function of the entry point instruction is to define the tasks to be executed at runtime after the container is started. Specifically, the entry point instruction will record the files that need to be read when the application is running after the container image is deployed as the container. According to the files that need to be read when the application is running, the application can be determined accordingly. Required resources.
- Step S302 Perform semantic analysis on the entry point instruction to determine the resources required by the application program in the container image to run.
- semantic analysis is performed on the entry point instructions obtained in the foregoing steps.
- Semantic analysis is a logical stage of the compilation process.
- the task of semantic analysis is to conduct contextual review of structurally correct code and conduct type review. Based on the characteristics of semantic analysis, because of the need to conduct context-related nature review, semantic analysis can determine the meaning of each code segment in the code.
- step S302 which includes step S401 to step S403.
- Step S401 Determine the executable file pointed to by the entry point instruction according to the semantic analysis result of the entry point instruction.
- Step S402 Parse the executable file to obtain a code segment corresponding to the resource in the executable file.
- Step S403 Determine the resource according to the code segment.
- the corresponding code segment in the entry point instruction will record some executable files that need to be called when the container is running.
- the resources needed to call these executable files are the resources needed for the application to run.
- the same parsing process is performed to obtain the content code of the executable file.
- a semantic analysis is performed on the content code of the executable file to determine the code segment corresponding to the resource in the content code of the executable file.
- the resources required for the application to run can be determined.
- the executable file may be at least one of a binary file, a script file, and a Jar package.
- different executable files also require different types of resources.
- the required resources are dynamic link libraries.
- the dynamic link library is a way to implement a shared function library, which enables a process to call functions that do not belong to its executable code, and is a necessary resource for calling binary files.
- the required resources are language interpreters and dynamic link libraries.
- the script file is executed by the language interpreter. When the language interpreter is executed, it reads a statement each time and performs a specific operation according to this statement; then reads the next statement, and so on, to achieve the script file implement.
- Jar package For the Jar package, the required resource is the Java virtual machine.
- Jar package also known as Java Archive File, is a file compression collection written in Java language.
- An executable Jar package is a self-contained (does not depend on other components, can be used in an independent manner for external use) Java application, it is stored in a specially configured JAR file, and can be executed without having to extract files or settings in advance path.
- the Java virtual machine is an abstract computer that runs all Java programs, and is the operating environment of the Java language.
- the code segment pointing to the executable file recorded in the entry point instruction is identified through semantic analysis. Generally, the code segment pointing to the executable file may directly record the name of the executable file. For example, based on the aforementioned entry point instruction example, it can be determined that the code segment "/bin/sh” indicates that the binary file /bin/sh needs to be called. The code segment "catalina.sh” indicates that the shell script file catalina.sh needs to be called.
- the binary file /bin/sh and the shell script file catalina.sh are determined. Similar to the processing of entry point instructions, the obtained executable file is also parsed to obtain the content code of the executable file, and the content code of the executable file is semantically analyzed to determine that the content code of the executable file corresponds to the application The code segment of the resources required by the program to run.
- the binary file /bin/sh For the binary file /bin/sh, through parsing and semantic analysis, it can be determined that the binary file /bin/sh needs to access the following four dynamic link libraries: /lib64/libtinfo.so.5, /lib64/libdl.so.2, / lib64/libc.so.6, /lib64/ld-linux-x86-64.so.2, the four dynamic link libraries are determined as resources required for the operation of the program in this embodiment.
- the required resources can be obtained, that is, these resources are determined as the resources required for the operation of the program in this embodiment.
- the composition of the Shell script file is relatively complex, it may include other Shell script files, script files in other languages, binary files or Jar packages, etc., so when parsing Shell script files, recursive analysis methods are used to parse the shell script files. . Since this embodiment does not improve the recursive analysis method itself, the specific content of the recursive analysis method will not be described in detail.
- different formats of entry point instructions may also adopt other methods to determine the resources required by the application program in the container image to run based on the semantic analysis result of the entry point instructions.
- Step S303 Determine the path information of the resource, and generate a pre-reading list corresponding to the container image according to the path information; wherein the pre-reading list is configured to respond to a download request for the container image, It is downloaded together with the container image.
- the path information of a resource refers to the information that records the storage location of the resource, and the resource can be accessed and loaded through the path information.
- the path information of the resource may have been recorded in the content code of the executable file, and accordingly, the path information of the resource can be determined at the same time when the resource is determined.
- the path information of the resource can be obtained through the addressing function of the system that deploys the container image. For example, in the Linux system commonly used in container technology, by using the pwd command, the location and path of the resource can be found to generate path information.
- the path information of the resource is further used to generate a pre-reading list.
- the pre-reading list includes at least the path information of the resources obtained above.
- the pre-reading list may also include other content.
- the executable file is a binary file
- the corresponding pre-reading list will also include the path information of the binary file itself.
- the executable file is a Jar package
- the corresponding pre-reading list will also include the path information of the Jar package itself.
- the pre-reading list After the pre-reading list is generated, the pre-reading list will be stored in the container image center in association with its corresponding container image.
- the file format of the pre-reading list is not limited in this embodiment. It can be determined according to the file system run by the container mirroring center, the execution device, or other devices, and it only needs to ensure that it can be read by the above device.
- the execution device requests to download a certain container image from the container mirror center
- the container image and its corresponding pre-reading list will be downloaded to the execution device together.
- the container image is loaded on the execution device, that is, when the container image is deployed as a container
- the pre-reading list is correspondingly read, and the resource is loaded through the path information of the resource included in the pre-reading list.
- the container image is deployed as the container to run, when the application in it is accessed, it can start quickly based on the loaded resources.
- the container image in this embodiment may already be stored on the container image center, or it may be uploaded to the container image center by the user through the execution device or other devices.
- the aforementioned steps S301 to S303 may be executed by the container mirroring center, or by other devices other than the container mirroring center and the execution device.
- steps S301 to S303 are executed by the container mirroring center and other devices other than the execution device, the container mirroring can be obtained from the container mirroring center or uploaded by the user.
- the container mirroring and pre-reading Read the list and return to the container mirror center for storage.
- the step of determining the path information of the resource can also be implemented by the following scheme: obtaining path setting information corresponding to the resource; determining the path information according to the path setting information .
- the path setting information is sent by the user through the execution device or other devices.
- the path setting information is edited and generated by the user, and records the resources required for the operation of the application in the container image.
- Path according to the path setting information, the path information of the resource can be generated accordingly.
- the container mirroring center can be provided with a preset data interface, which is used to provide data communication between the container mirroring center and the execution device.
- the user operating the execution device can be based on the aforementioned
- the data communication provided by the interface sends path setting information to the container mirroring center to generate path information of the resource.
- the method of this embodiment provides a solution in which the user actively specifies the path information of the resource.
- the user actively specifies the path information of the resource, which can improve the execution efficiency of the method of this embodiment, while also enriching
- the method in this embodiment can be applied to various different implementation scenarios.
- one or more embodiments of this specification also provide a method for loading a container image, which is applied to an execution device.
- the method for loading the container image includes steps S501 to S503.
- Step S501 Send a download request of the container image, and obtain the container image and its corresponding pre-reading list.
- the execution device sends a download request for the container image to the container image center. After the download request is passed by the container image center, the execution device can download the container image pointed to by the download request from the container image center, and the container image The corresponding pre-reading list.
- Step S502 In response to the event of loading the container image, read the pre-reading list, and determine the path information of the resources required by the application program in the container image to run.
- the execution device loads the previously downloaded container image, so that when the container image is deployed as a container, it will read the pre-reading list corresponding to the container image accordingly.
- the path information of the resources included in the pre-reading list can be obtained. This resource is the resource required for the running of the application in the container image.
- Step S503 According to the path information, load the resources required for the operation of the application in the container image.
- the execution device accesses the address recorded in the path information according to the path information obtained from the pre-reading list, and loads the resources required for the operation of the application program in the container image.
- the pre-reading list and the container image will be downloaded together, and when the container image is loaded, the pre-reading list will be read accordingly, and the location access will be based on the path information obtained by reading. And load the resources required by the application in the container image to run. In this way, when the application is accessed, its required resources have been successfully loaded, and the application can be started quickly.
- one or more embodiments of this specification also provide a container image providing device, including: a parsing module 601, configured to obtain and parse the Dockerfile file of the container image to obtain the Dockerfile The entry point instruction in the file; the determining module 602 is configured to perform semantic analysis on the entry point instruction to determine the resources required for the operation of the application in the container image; the generating module 603 is configured to determine the resource And generate a pre-reading list corresponding to the container image according to the path information; wherein the pre-reading list is configured to be in response to a download request for the container image and to be combined with the container image Was downloaded.
- a parsing module 601 configured to obtain and parse the Dockerfile file of the container image to obtain the Dockerfile The entry point instruction in the file
- the determining module 602 is configured to perform semantic analysis on the entry point instruction to determine the resources required for the operation of the application in the container image
- the generating module 603 is configured to determine the resource And generate a pre-reading list corresponding to the
- the determining module 602 is specifically configured to determine the executable file pointed to by the entry point instruction according to the semantic analysis result of the entry point instruction; parse the executable file to obtain the The code segment in the executable file corresponding to the resource; and the resource is determined according to the code segment.
- the generating module 603 is specifically configured to obtain path setting information corresponding to the resource; and determine the path information according to the path setting information.
- the device for providing container image in the foregoing embodiment is used to implement the corresponding method for providing container image in the foregoing embodiment, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.
- one or more embodiments of this specification also provide a container image loading device, including: an obtaining module 701 configured to send a download request of the container image, and obtain the container image and The corresponding pre-reading list; the reading module 702 is configured to read the pre-reading list in response to the event of loading the container image, and determine the path information of the resources required by the application program in the container image to run The loading module 703 is configured to load the resources required for the operation of the application in the container image according to the path information.
- an obtaining module 701 configured to send a download request of the container image, and obtain the container image and The corresponding pre-reading list
- the reading module 702 is configured to read the pre-reading list in response to the event of loading the container image, and determine the path information of the resources required by the application program in the container image to run
- the loading module 703 is configured to load the resources required for the operation of the application in the container image according to the path information.
- the container image loading device of the foregoing embodiment is used to implement the corresponding container image loading method in the foregoing embodiment, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.
- one or more embodiments of this specification also provide an electronic device, including a memory, a processor, and a computer program stored in the memory and running on the processor, and the processor executes the program
- the method for providing the container image as described in any of the above embodiments or the method for loading the container image as described in any of the above embodiments is realized.
- FIG. 8 shows a more specific hardware structure diagram of an electronic device provided by this embodiment.
- the device may include a processor 1010, a memory 1020, an input/output interface 1030, a communication interface 1040, and a bus 1050.
- the processor 1010, the memory 1020, the input/output interface 1030, and the communication interface 1040 realize the communication connection between each other in the device through the bus 1050.
- the processor 1010 may be implemented by a general CPU (Central Processing Unit, central processing unit), microprocessor, application specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, etc., for execution related Program to implement the technical solutions provided in the embodiments of this specification.
- CPU Central Processing Unit
- ASIC Application Specific Integrated Circuit
- the memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory, random access memory), static storage device, dynamic storage device, etc.
- the memory 1020 may store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, related program codes are stored in the memory 1020 and called and executed by the processor 1010.
- the input/output interface 1030 is used to connect an input/output module to realize information input and output.
- the input/output/module can be configured in the device as a component (not shown in the figure), or can be connected to the device to provide corresponding functions.
- the input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and an output device may include a display, a speaker, a vibrator, an indicator light, and the like.
- the communication interface 1040 is used to connect a communication module (not shown in the figure) to realize the communication interaction between the device and other devices.
- the communication module can realize communication through wired means (such as USB, network cable, etc.), or through wireless means (such as mobile network, WIFI, Bluetooth, etc.).
- the bus 1050 includes a path to transmit information between various components of the device (for example, the processor 1010, the memory 1020, the input/output interface 1030, and the communication interface 1040).
- the above device only shows the processor 1010, the memory 1020, the input/output interface 1030, the communication interface 1040, and the bus 1050, in the specific implementation process, the device may also include the equipment necessary for normal operation. Other components.
- the above-mentioned device may also include only the components necessary to implement the solutions of the embodiments of the present specification, and not necessarily include all the components shown in the figures.
- one or more embodiments of this specification also provide a container mirroring system, including: the container mirroring provision device as described in any of the above embodiments; and the container mirroring loading as described in any of the above embodiments Device.
- the device for providing container mirroring and the device for loading container mirroring included in it their respective implementation processes, and the interaction process between the two have been described in detail in the foregoing embodiments. Therefore, it will not be repeated in this embodiment.
- the container mirroring system of this embodiment includes the device for providing container mirroring and the device for loading container mirroring as described in the foregoing embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.
- the methods in one or more embodiments of this specification can be executed by a single device, such as a computer or a server.
- the method of this embodiment can also be applied in a distributed scenario, and it is completed by the cooperation of multiple devices.
- one of the multiple devices can only perform one or more steps in the method of one or more embodiments of this specification, and the multiple devices will perform each other. Interact to complete the described method.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computational Linguistics (AREA)
- Stored Programmes (AREA)
Abstract
一种容器镜像的提供方法、加载方法及相关设备和系统;所述提供方法中,获取容器镜像中的入口点指令,通过对所述入口点指令进行语义分析,确定所述容器镜像所需的资源以及资源的路径信息,并生成包括路径信息的预读列表,该预读列表能够与容器镜像一起被下载;所述加载方法中,在发送容器镜像的下载请求,并相应的获取所述容器镜像和其对应的预读列表后,于容器镜像被读取时,相应的读取所述预读列表得到容器镜像所需的资源的路径信息,访问并加载所述容器镜像所需的资源。
Description
本说明书一个或多个实施例涉及计算机技术技术领域,尤其涉及一种容器镜像的提供方法、加载方法及相关设备和系统。
容器(container)技术是一种轻量级的虚拟化技术。在某一节点中部署容器时,先需要将该容器的容器镜像下载至该容器。容器镜像是指部署容器时所需的各种数据文件,包括操作系统、软件环境以及应用程序等内容。
在相关技术中,容器镜像被部署为容器后运行时,其包括的应用程序的启动速度是容器运行质量和效率的一个重要影响因素,所以如何提升容器中应用程序的启动速度是容器技术领域亟待解决的一项关键问题。
发明内容
有鉴于此,本说明书一个或多个实施例的目的在于提出一种容器镜像的提供方法、加载方法及相关设备和系统。
基于上述目的,本说明书一个或多个实施例提供了一种容器镜像的提供方法,包括:获取容器镜像的Dockerfile文件并解析,得到所述Dockerfile文件中的入口点指令;对所述入口点指令进行语义分析,确定所述容器镜像中的应用程序运行所需的资源;确定所述资源的路径信息,并根据所述路径信息生成与所述容器镜像对应的预读列表;其中,所述预读列表被配置为响应于对所述容器镜像的下载请求,与所述容器镜像一并被下载。
基于同一发明构思,本说明书一个或多个实施例还提供了一种容器镜像的加载方法,包括:发送容器镜像的下载请求,获取所述容器镜像和其对应的预读列表;响应于加载所述容器镜像的事件,读取所述预读列表,确定所述容器镜像中的应用程序运行所需的资源的路径信息;根据所述路径信息,加载所述容器镜像中的应用程序运行所需的资源。
基于同一发明构思,本说明书一个或多个实施例还提供了一种容器镜像的提供装 置,包括:解析模块,被配置为获取容器镜像的Dockerfile文件并解析,得到所述Dockerfile文件中的入口点指令;确定模块,被配置为对所述入口点指令进行语义分析,确定所述容器镜像中的应用程序运行所需的资源;生成模块,被配置为确定所述资源的路径信息,并根据所述路径信息生成与所述容器镜像对应的预读列表;其中,所述预读列表被配置为响应于对所述容器镜像的下载请求,与所述容器镜像一并被下载。
基于同一发明构思,本说明书一个或多个实施例还提供了一种容器镜像的加载装置,包括:获取模块,被配置为发送容器镜像的下载请求,获取所述容器镜像和其对应的预读列表;读取模块,被配置为响应于加载所述容器镜像的事件,读取所述预读列表,确定所述容器镜像中的应用程序运行所需的资源的路径信息;加载模块,被配置为根据所述路径信息,加载所述容器镜像中的应用程序运行所需的资源。
基于同一发明构思,本说明书一个或多个实施例还提供了一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述程序时实现如上任意一项所述的容器镜像的提供方法,或者,如上任意一项所述的容器镜像的加载方法。
基于同一发明构思,本说明书一个或多个实施例还提供了一种容器镜像系统,包括:如上任意一项所述的容器镜像的提供装置;以及,如上任意一项所述的容器镜像的加载装置。
从上面所述可以看出,本说明书一个或多个实施例提供的容器镜像的提供方法、加载方法及相关设备和系统,对于容器镜像,通过语义分析方法确定容器镜像的Dockerfile文件中的入口点指令记载的容器镜像中的应用程序运行所需的资源,并将资源的路径信息生成预读列表;该预读列表能够在容器镜像被请求时,与容器镜像一并下载,并在加载容器镜像时,读取预读列表以加载应用程序运行所需的资源,从而使得容器镜像部署为容器以运行时,能够实现应用程序的快速启动,进而提升容器运行的质量和效率。
为了更清楚地说明本说明书一个或多个实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显见地,下面描述中的附图仅仅是本说明书一个或多个实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为相关技术中的实施场景示意图;
图2为本说明书一个或多个实施例的实施场景示意图;
图3为本说明书一个或多个实施例的容器镜像的提供方法流程图;
图4为本说明书一个或多个实施例中确定容器镜像中的应用程序运行所需的资源步骤的流程图;
图5为本说明书一个或多个实施例的容器镜像的加载方法流程图;
图6为本说明书一个或多个实施例的容器镜像的提供装置结构示意图;
图7为本说明书一个或多个实施例的容器镜像的加载装置结构示意图;
图8为本说明书一个或多个实施例的电子设备结构示意图。
为使本公开的目的、技术方案和优点更加清楚明白,以下结合具体实施例,并参照附图,对本公开进一步详细说明。
需要说明的是,除非另外定义,本说明书一个或多个实施例使用的技术术语或者科学术语应当为本公开所属领域内具有一般技能的人士所理解的通常意义。本说明书一个或多个实施例中使用的“第一”、“第二”以及类似的词语并不表示任何顺序、数量或者重要性,而只是用来区分不同的组成部分。“包括”或者“包含”等类似的词语意指出现该词前面的元件或者物件涵盖出现在该词后面列举的元件或者物件及其等同,而不排除其他元件或者物件。“连接”或者“相连”等类似的词语并非限定于物理的或者机械的连接,而是可以包括电性的连接,不管是直接的还是间接的。
本说明书一个或多个实施例涉及的技术方案,均会涉及容器技术中的容器和容器镜像这两个概念。
容器,基于容器镜像创建生成。容器可以理解为容器镜像的一个实例,其让用户可以打包应用及程序依赖包到一个可移植的容器内,然后部署到支持容器的Linux设备上(常见Linux发布版本基本都支持)。同时,实现了进程级别的虚拟化。
容器镜像(Image)是构建容器的基础,其是一种分层结构的文件系统。一个只读层被称为容器镜像,一个容器镜像是永久不会变的。由于容器技术使用统一的文件系统,认为整个文件系统是以读写方式挂载的。但是所有的变更都发生顶层的可写层,而下层 的原始的只读镜像文件并未变化。
也就是说,容器镜像提供了只读层,而在只读层上添加了读写层后便构成容器,也即容器镜像在设备上部署为容器。
参考图1,示出了相关技术中的容器技术实施场景。其中,容器镜像中心被配置为存储容器镜像,向执行设备提供容器镜像的和和下载服务。执行设备是用于部署容器的设备,其可以是物理设备(例如服务器),也可以是虚拟设备(例如虚拟机)。执行设备可以向容器镜像中心请求其存储的容器镜像,然后从容器镜像中心下载容器镜像,下载后的容器镜像即可以在执行设备上部署成为容器以运行。
执行设备从容器镜像中心下载获得容器镜像后,部署成为容器运行。在运行中,当容器中的应用程序被访问时,会加载应用程序运行所需的资源。这种在应用程序被访问时才相应加载资源的方式,造成了容器中的应用程序启动速度偏慢,影响了容器运行的质量和效率。
参考图2,示出了本说明书的技术方案的实施场景。本说明书一个或多个实施例提供了一种容器镜像的提供方法、加载方法及相关设备和系统,对于容器镜像,通过语义分析方法确定容器镜像的Dockerfile文件中的入口点指令记载的容器镜像中的应用程序运行所需的资源,并将资源的路径信息生成预读列表;该预读列表能够在容器镜像被请求时,与容器镜像一并下载,并在加载容器镜像时,读取预读列表以加载应用程序运行所需的资源;也即,不再是应用程序被访问时才加载所述的资源,而是在容器镜像部署为容器以运行时,便加载应用程序运行所需的资源,这样便有效的加快了容器运行时应用程序的启动速度,进而提升了容器运行的质量和效率。
以下结合附图,详细说明本申请各实施例提供的技术方案。
本说明书一个或多个实施例提供了一种容器镜像的提供方法,参考图3,所述的容器镜像的提供方法,包括步骤S301~S303。
步骤S301、获取容器镜像的Dockerfile文件并解析,得到所述Dockerfile文件中的入口点指令。
本步骤中,对于容器镜像,获取其对应的Dockerfile文件。Dockerfile是由一系列命令和参数构成的脚本,这些命令应用于基础容器镜像并最终创建一个新的容器镜像,它们简化了从头到尾的流程并极大的简化了部署工作。Dockerfile从FROM指令开始,紧接着跟随者各种方法,指令和参数,其产出为一个新的可以用于创建容器的容器镜像。
在获取到Dockerfile文件后,对Dockerfile文件进行解析以得到Dockerfile文件的内容代码,也即构成Dockerfile文件的若干条指令。以下为一个Dockerfile文件的内容代码示例:
FROM python:2.7
MAINTAINER ALI<****@***.com>
COPY./app
WORKDIR/app
RUN pip install -r requirements.txt
EXPOSE 5000
ENTRYPOINT[/bin/sh -c"catalina.sh\run"]
CMD["app.py"]
上述Dockerfile文件的内容代码中,“ENTRYPOINT”即为入口点指令。入口点指令的作用为定义容器启动以后在运行时要执行的任务。具体的,入口点指令会记载容器镜像部署为容器运行后,其中的应用程序运行时需要读取的文件,根据应用程序运行时需要读取的文件,也就能相应的确定应用程序运行时所需的资源。
步骤S302、对所述入口点指令进行语义分析,确定所述容器镜像中的应用程序运行所需的资源。
本步骤中,对前述步骤中获得的入口点指令进行语义分析。语义分析,是编译过程的一个逻辑阶段,语义分析的任务是对结构上正确的代码进行上下文有关性质的审查,进行类型审查。基于语义分析的特点,由于要进行上下文有关性质的审查,所以语义分析能够确定代码中的各个代码段的含义。
本实施例中,通过对入口点指令进行语义分析,即能够确定入口点指令中对应于应用程序运行时需要读取的文件的代码段,从而进一步确定容器镜像中的应用程序运行所需的资源。
参考图4,为步骤S302的一种可选的具体实施方式,包括步骤S401~步骤S403。
步骤S401、根据所述入口点指令的语义分析结果,确定所述入口点指令指向的可执行文件。
步骤S402、解析所述可执行文件,得到所述可执行文件中的对应于所述资源的代 码段。
步骤S403、根据所述代码段,确定所述资源。
入口点指令中相应的代码段会记载容器运行时需要调用的一些可执行文件。相应的,调用这些可执行文件时所需的资源,也就是应用程序运行所需的资源。类似于对入口点指令的处理,对于可执行文件,同样的进行解析处理,得到可执行文件的内容代码。对可执行文件的内容代码进行语义分析,来确定可执行文件的内容代码中,对应于所述的资源的代码段。相应的,根据这些代码段,即能够确定应用程序运行所需的资源。
其中,可执行文件可以是二进制文件、脚本文件、Jar包中的至少一种。相应的,不同的可执行文件也所需不同类型的资源。具体的:于二进制文件,其所需的资源为动态链接库。动态链接库是实现共享函数库的一种方式,其使进程可以调用不属于其可执行代码的函数,是调用二进制文件所必备的资源。
对于脚本文件,基于编写脚本所使用的语言(如perl、python、ruby、Shell等),其所需的资源为语言解释器和动态链接库。脚本文件是通过语言解释器执行的,语言解释器在执行时,每次读入一条语句,并且根据这条语句执行特定的操作;然后再读入下一条语句,依次类推,以实现脚本文件的执行。
对于Jar包,其所需的资源为Java虚拟机。Jar包,也称为Java Archive File,其是Java语言编写的文件压缩集合。一个可执行的Jar包是一个自包含(不依赖其他组件,能够以独立的方式供外部使用)的Java应用程序,它存储在特别配置的JAR文件中,可以接执行而无需事先提取文件或者设置路径。Java虚拟机是运行所有Java程序的抽象计算机,是Java语言的运行环境。
仍基于前述的入口点指令的示例:ENTRYPOINT[/bin/sh -c"catalina.sh\run"]。通过语义分析识别出入口点指令中记载的指向可执行文件的代码段,一般的,该指向可执行文件的代码段,可以是直接记载了可执行文件的名称。例如,基于前述的入口点指令的示例,可以确定:代码段“/bin/sh”表明需要调用/bin/sh这个二进制文件。而代码段“catalina.sh”表明需要调用catalina.sh这个Shell脚本文件。
确定了二进制文件/bin/sh和Shell脚本文件catalina.sh。类似于对于入口点指令的处理,对于得到的可执行文件也进行解析得到可执行文件的内容代码,对可执行文件的内容代码进行语义分析,从而确定可执行文件的内容代码中,对应于应用程序运行所需的资源的代码段。
对于二进制文件/bin/sh,通过解析和语义分析,可以确定二进制文件/bin/sh需要访问以下四个动态链接库:/lib64/libtinfo.so.5、/lib64/libdl.so.2、/lib64/libc.so.6、/lib64/ld-linux-x86-64.so.2,该四个动态链接库即被确定为本实施例中用程序运行所需的资源。
对于Shell脚本文件catalina.sh,通过解析和语义分析,即能够得到其所需的资源,即这些资源被确定为本实施例中用程序运行所需的资源。需要说明的是,由于Shell脚本文件的组成较为复杂,其可能包括其他的Shell脚本文件、其他语言的脚本文件、二进制文件或Jar包等,故在解析Shell脚本文件时,通过递归解析方法进行解析。由于本实施例对于递归解析方法本身并无改进,故对于递归解析方法的具体内容不再详述。
此外,在一些其他的实施方式中,入口点指令的不同格式,也可以采用其他的方法来基于入口点指令的语义分析结果,来确定容器镜像中的应用程序运行所需的资源。
步骤S303、确定所述资源的路径信息,并根据所述路径信息生成与所述容器镜像对应的预读列表;其中,所述预读列表被配置为响应于对所述容器镜像的下载请求,与所述容器镜像一并被下载。
本步骤中,对于前述步骤中确定出的容器镜像中的应用程序运行所需的资源,首先确定该资源的路径信息。资源的路径信息,是指记载资源的存储位置的信息,通过该路径信息可以访问进而加载所述的资源。
在一些实施方式中,资源的路径信息可能已经记载在可执行文件的内容代码中,相应的在前述确定资源时便可以同时确定资源的路径信息。在另在一些实施方式中,于确定资源后,可以通过部署容器镜像的系统自带的寻址功能来获得资源的路径信息。例如,在容器技术常用的linux系统下,通过使用pwd命令,即能够查找到资源的位置和路径,从而生成路径信息。
在得到资源的路径信息之后,进一步使用资源的路径信息,生成一预读列表。该预读列表中,至少包括有前述得到的资源的路径信息。此外,根据资源对应的可执行文件的类型,预读列表也可以包括其他内容。例如,当可执行文件为二进制文件时,相应的预读列表中除了包括动态链接库的路径信息以外,还会包括该二进制文件本身的路径信息。当可执行文件为Jar包时,相应的预读列表中除了包括Java虚拟机以外,还会包括该Jar包本身的路径信息。
生成预读列表后,该预读列表会与其对应的容器镜像相关联的被存储于容器镜像 中心。对于预读列表的文件格式,本实施例中不做限定,其可以根据容器镜像中心、执行设备或是其他设备所运行的文件系统而相应确定,只需要保证能够被上述设备读取即可。
在使用时,当执行设备向容器镜像中心请求下载某一容器镜像时,该容器镜像与其对应的预读列表将会被一并下载至执行设备。后续的,在执行设备上加载容器镜像,即将容器镜像部署为容器时,相应的会读取预读列表,通过预读列表中包括的资源的路径信息,加载所述的资源。这样,在容器镜像部署为容器运行后,其中的应用程序被访问时,即能够基于已经加载的资源,实现快速的启动。
需要说明的是,本实施例中的容器镜像,其可以是已经存储在容器镜像中心上的,也可以是用户通过执行设备或者其他设备将要上传到容器镜像中心的。也就是说,上述的步骤S301至步骤S303,可以由容器镜像中心来执行,也可以由容器镜像中心和执行设备之外的其他设备来执行。当步骤S301至步骤S303由容器镜像中心和执行设备之外的其他设备来执行时,容器镜像可以从容器镜像中心获取,或是由用户上传,而在生成预读列表后,将容器镜像和预读列表一并返回至容器镜像中心进行存储。
作为一个可选的实施例,确定所述资源的路径信息的步骤,还可以通过以下方案实现:获取对应于所述资源的路径设定信息;根据所述路径设定信息,确定所述路径信息。
本实施例中,所述的路径设定信息是由用户通过执行设备或者是其他设备发送的,该路径设定信息由用户编辑并生成,记载了容器镜像中的应用程序运行所需的资源的路径,根据该路径设定信息即能够相应的生成所述资源的路径信息。
具体的,以容器镜像中心和执行设备为例,容器镜像中心可以设置有预设的数据接口,该接口用于提供容器镜像中心与执行设备之间的数据通信,用户操作执行设备,可以基于前述接口提供的数据通信向容器镜像中心发送路径设定信息,用以生成述资源的路径信息。
本实施例的方法,提供一种由用户主动的指定资源的路径信息的方案,在一些情况下,由用户主动的指定资源的路径信息,能够提升本实施例的方法的执行效率,同时也丰富了确定所述资源的路径信息的手段,使得本实施例的方法能够适用于各种不同的实施场景。
基于同一发明构思,本说明书一个或多个实施例还提供了一种容器镜像的加载方 法,该方法应用于执行设备。
参考图5,所述的容器镜像的加载方法,包括步骤S501~S503。
步骤S501、发送容器镜像的下载请求,获取所述容器镜像和其对应的预读列表。
本步骤中,执行设备向容器镜像中心发送对容器镜像的下载请求,当下载请求被容器镜像中心通过后,执行设备即能够从容器镜像中心下载获得下载请求所指向的容器镜像,以及该容器镜像对应的预读列表。
步骤S502、响应于加载所述容器镜像的事件,读取所述预读列表,确定所述容器镜像中的应用程序运行所需的资源的路径信息。
本步骤中,执行设备加载前述下载到的容器镜像,以实现将容器镜像部署为容器时,会相应的读取该容器镜像对应的预读列表。通过读取预读列表,即能够获得预读列表中包括的资源的路径信息。该资源即是容器镜像中的应用程序运行所需的资源。
步骤S503、根据所述路径信息,加载所述容器镜像中的应用程序运行所需的资源。
本步骤中,执行设备根据由预读列表获得的路径信息,访问路径信息记载的地址,并加载容器镜像中的应用程序运行所需的资源。
可见,本实施例的容器镜像的加载方法,预读列表和容器镜像会被一并下载,并且在加载容器镜像时,会相应的读取预读列表,根据读取得到的路径信息,方位访问并加载容器镜像中的应用程序运行所需的资源。这样,当应用程序被访问时,其所需的资源已经被成功加载,应用程序便能够实现快速的启动。
基于同一发明构思,参考图6,本说明书一个或多个实施例还提供了一种容器镜像的提供装置,包括:解析模块601,被配置为获取容器镜像的Dockerfile文件并解析,得到所述Dockerfile文件中的入口点指令;确定模块602,被配置为对所述入口点指令进行语义分析,确定所述容器镜像中的应用程序运行所需的资源;生成模块603,被配置为确定所述资源的路径信息,并根据所述路径信息生成与所述容器镜像对应的预读列表;其中,所述预读列表被配置为响应于对所述容器镜像的下载请求,与所述容器镜像一并被下载。
作为一个可选的实施例,所述确定模块602,具体被配置为根据所述入口点指令的语义分析结果,确定所述入口点指令指向的可执行文件;解析所述可执行文件,得到所述可执行文件中的对应于所述资源的代码段;根据所述代码段,确定所述资源。
作为一个可选的实施例,所述生成模块603,具体被配置为获取对应于所述资源的路径设定信息;根据所述路径设定信息,确定所述路径信息。
为了描述的方便,描述以上装置时以功能分为各种模块分别描述。当然,在实施本说明书一个或多个实施例时可以把各模块的功能在同一个或多个软件和/或硬件中实现。
上述实施例的容器镜像的提供装置用于实现前述实施例中相应的容器镜像的提供方法,并且具有相应的方法实施例的有益效果,在此不再赘述。
基于同一发明构思,参考图7,本说明书一个或多个实施例还提供了一种容器镜像的加载装置,包括:获取模块701,被配置为发送容器镜像的下载请求,获取所述容器镜像和其对应的预读列表;读取模块702,被配置为响应于加载所述容器镜像的事件,读取所述预读列表,确定所述容器镜像中的应用程序运行所需的资源的路径信息;加载模块703,被配置为根据所述路径信息,加载所述容器镜像中的应用程序运行所需的资源。
为了描述的方便,描述以上装置时以功能分为各种模块分别描述。当然,在实施本说明书一个或多个实施例时可以把各模块的功能在同一个或多个软件和/或硬件中实现。
上述实施例的容器镜像的加载装置用于实现前述实施例中相应的容器镜像的加载方法,并且具有相应的方法实施例的有益效果,在此不再赘述。
基于同一发明构思,本说明书一个或多个实施例还提供了一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述程序时实现如上任意一实施例所述的容器镜像的提供方法,或者,如上任意一实施例所述的容器镜像的加载方法。
图8示出了本实施例所提供的一种更为具体的电子设备硬件结构示意图,该设备可以包括:处理器1010、存储器1020、输入/输出接口1030、通信接口1040和总线1050。其中处理器1010、存储器1020、输入/输出接口1030和通信接口1040通过总线1050实现彼此之间在设备内部的通信连接。
处理器1010可以采用通用的CPU(Central Processing Unit,中央处理器)、微处理器、应用专用集成电路(Application Specific Integrated Circuit,ASIC)、或者一个或多个集成电路等方式实现,用于执行相关程序,以实现本说明书实施例所提供的技术方 案。
存储器1020可以采用ROM(Read Only Memory,只读存储器)、RAM(Random Access Memory,随机存取存储器)、静态存储设备,动态存储设备等形式实现。存储器1020可以存储操作系统和其他应用程序,在通过软件或者固件来实现本说明书实施例所提供的技术方案时,相关的程序代码保存在存储器1020中,并由处理器1010来调用执行。
输入/输出接口1030用于连接输入/输出模块,以实现信息输入及输出。输入输出/模块可以作为组件配置在设备中(图中未示出),也可以外接于设备以提供相应功能。其中输入设备可以包括键盘、鼠标、触摸屏、麦克风、各类传感器等,输出设备可以包括显示器、扬声器、振动器、指示灯等。
通信接口1040用于连接通信模块(图中未示出),以实现本设备与其他设备的通信交互。其中通信模块可以通过有线方式(例如USB、网线等)实现通信,也可以通过无线方式(例如移动网络、WIFI、蓝牙等)实现通信。
总线1050包括一通路,在设备的各个组件(例如处理器1010、存储器1020、输入/输出接口1030和通信接口1040)之间传输信息。
需要说明的是,尽管上述设备仅示出了处理器1010、存储器1020、输入/输出接口1030、通信接口1040以及总线1050,但是在具体实施过程中,该设备还可以包括实现正常运行所必需的其他组件。此外,本领域的技术人员可以理解的是,上述设备中也可以仅包含实现本说明书实施例方案所必需的组件,而不必包含图中所示的全部组件。
基于同一发明构思,本说明书一个或多个实施例还提供了容器镜像系统,包括:如上任意一实施例所述的容器镜像的提供装置;以及,如上任意一实施例所述的容器镜像的加载装置。
本实施例的容器镜像系统中,其包括的容器镜像的提供装置和容器镜像的加载装置,其各自的实施过程,以及二者之间的交互过程,在前述各实施例中已进行了详细说明,故本实施例中不再赘述。
本实施例的容器镜像系统,其包括了前述实施例所述的容器镜像的提供装置和容器镜像的加载装置,具有相应的方法实施例的有益效果,在此不再赘述。
需要说明的是,本说明书一个或多个实施例的方法可以由单个设备执行,例如一台计算机或服务器等。本实施例的方法也可以应用于分布式场景下,由多台设备相互配 合来完成。在这种分布式场景的情况下,这多台设备中的一台设备可以只执行本说明书一个或多个实施例的方法中的某一个或多个步骤,这多台设备相互之间会进行交互以完成所述的方法。
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。
所属领域的普通技术人员应当理解:以上任何实施例的讨论仅为示例性的,并非旨在暗示本公开的范围(包括权利要求)被限于这些例子;在本公开的思路下,以上实施例或者不同实施例中的技术特征之间也可以进行组合,步骤可以以任意顺序实现,并存在如上所述的本说明书一个或多个实施例的不同方面的许多其它变化,为了简明它们没有在细节中提供。
本说明书一个或多个实施例旨在涵盖落入所附权利要求的宽泛范围之内的所有这样的替换、修改和变型。因此,凡在本说明书一个或多个实施例的精神和原则之内,所做的任何省略、修改、等同替换、改进等,均应包含在本公开的保护范围之内。
Claims (13)
- 一种容器镜像的提供方法,包括:获取容器镜像的Dockerfile文件并解析,得到所述Dockerfile文件中的入口点指令;对所述入口点指令进行语义分析,确定所述容器镜像中的应用程序运行所需的资源;确定所述资源的路径信息,并根据所述路径信息生成与所述容器镜像对应的预读列表;其中,所述预读列表被配置为响应于对所述容器镜像的下载请求,与所述容器镜像一并被下载。
- 根据权利要求1所述的容器镜像的提供方法,所述对所述入口点指令进行语义分析,确定所述容器镜像中的应用程序运行所需的资源,包括:根据所述入口点指令的语义分析结果,确定所述入口点指令指向的可执行文件;解析所述可执行文件,得到所述可执行文件中的对应于所述资源的代码段;根据所述代码段,确定所述资源。
- 根据权利要求2所述的容器镜像的提供方法,所述可执行文件包括二进制文件、脚本文件、Jar包中的至少一种。
- 根据权利要求3所述的容器镜像的提供方法,所述可执行文件包括脚本文件,且所述脚本文件基于Shell语言;所述解析所述可执行文件,包括:通过递归解析方法解析所述可执行文件。
- 根据权利要求1所述的容器镜像的提供方法,所述确定所述资源的路径信息,包括:获取对应于所述资源的路径设定信息;根据所述路径设定信息,确定所述路径信息。
- 根据权利要求1所述的容器镜像的提供方法,所述资源包括:动态库、语言解释器、Java虚拟机中的至少一种。
- 一种容器镜像的加载方法,包括:发送容器镜像的下载请求,获取所述容器镜像和其对应的预读列表;响应于加载所述容器镜像的事件,读取所述预读列表,确定所述容器镜像中的应用程序运行所需的资源的路径信息;根据所述路径信息,加载所述容器镜像中的应用程序运行所需的资源。
- 一种容器镜像的提供装置,包括:解析模块,被配置为获取容器镜像的Dockerfile文件并解析,得到所述Dockerfile文件中的入口点指令;确定模块,被配置为对所述入口点指令进行语义分析,确定所述容器镜像中的应用程序运行所需的资源;生成模块,被配置为确定所述资源的路径信息,并根据所述路径信息生成与所述容器镜像对应的预读列表;其中,所述预读列表被配置为响应于对所述容器镜像的下载请求,与所述容器镜像一并被下载。
- 根据权利要求8所述的装置,所述确定模块,具体被配置为根据所述入口点指令的语义分析结果,确定所述入口点指令指向的可执行文件;解析所述可执行文件,得到所述可执行文件中的对应于所述资源的代码段;根据所述代码段,确定所述资源。
- 根据权利要求8所述的装置,所述生成模块,具体被配置为获取对应于所述资源的路径设定信息;根据所述路径设定信息,确定所述路径信息。
- 一种容器镜像的加载装置,包括:获取模块,被配置为发送容器镜像的下载请求,获取所述容器镜像和其对应的预读列表;读取模块,被配置为响应于加载所述容器镜像的事件,读取所述预读列表,确定所述容器镜像中的应用程序运行所需的资源的路径信息;加载模块,被配置为根据所述路径信息,加载所述容器镜像中的应用程序运行所需的资源。
- 一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述程序时实现如权利要求1至6中任意一项所述的容器镜像的提供方法,或者,如权利要求7所述的容器镜像的加载方法。
- 一种容器镜像系统,包括:如权利要求8至10任意一项所述的容器镜像的提供装置;以及,如权利要求11所述的容器镜像的加载装置。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010097850.3A CN111324421B (zh) | 2020-02-18 | 2020-02-18 | 一种容器镜像的提供方法、加载方法及相关设备和系统 |
| CN202010097850.3 | 2020-02-18 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2021164367A1 true WO2021164367A1 (zh) | 2021-08-26 |
Family
ID=71163542
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2020/132681 Ceased WO2021164367A1 (zh) | 2020-02-18 | 2020-11-30 | 一种容器镜像的提供方法、加载方法及相关设备和系统 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN111324421B (zh) |
| WO (1) | WO2021164367A1 (zh) |
Cited By (10)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113946799A (zh) * | 2021-12-21 | 2022-01-18 | 深圳佑驾创新科技有限公司 | 应用程序源码保护方法以及服务端 |
| CN114090183A (zh) * | 2021-11-25 | 2022-02-25 | 北京字节跳动网络技术有限公司 | 一种应用启动方法、装置、计算机设备和存储介质 |
| CN114237760A (zh) * | 2021-12-21 | 2022-03-25 | 华北电力大学 | 一种将工业机理模型封装为容器镜像并发布web服务的方法 |
| CN114237686A (zh) * | 2021-11-19 | 2022-03-25 | 北京百度网讯科技有限公司 | 安装包生成方法、装置、电子设备及存储介质 |
| CN114595034A (zh) * | 2022-03-07 | 2022-06-07 | 中南大学 | 一种容器镜像体积缩小方法、存储器及装置 |
| CN114697313A (zh) * | 2022-03-15 | 2022-07-01 | 浪潮云信息技术股份公司 | 一种基于镜像的文件下载方法 |
| CN115658238A (zh) * | 2022-11-10 | 2023-01-31 | 深圳开源互联网安全技术有限公司 | 容器镜像下载方法、装置、终端设备以及存储介质 |
| CN116954831A (zh) * | 2023-09-20 | 2023-10-27 | 中国电子科技集团公司第十五研究所 | 基于装配文件生成容器镜像包的方法及系统 |
| CN119004464A (zh) * | 2024-08-21 | 2024-11-22 | 北京火山引擎科技有限公司 | 容器镜像中恶意文件的检测方法、装置、介质、设备及产品 |
| CN119442248A (zh) * | 2024-10-22 | 2025-02-14 | 上海交通大学 | 恶意容器镜像的威胁评估与多维度检测系统及方法 |
Families Citing this family (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111324421B (zh) * | 2020-02-18 | 2023-04-07 | 支付宝(杭州)信息技术有限公司 | 一种容器镜像的提供方法、加载方法及相关设备和系统 |
| CN119557042A (zh) * | 2023-09-04 | 2025-03-04 | 华为云计算技术有限公司 | 提供容器服务的方法、容器系统及相关装置 |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20170054759A1 (en) * | 2015-08-19 | 2017-02-23 | Samsung Sds Co., Ltd. | Method and apparatus for security checking of image for container |
| CN109634657A (zh) * | 2018-12-14 | 2019-04-16 | 武汉烽火信息集成技术有限公司 | 一种微服务打包部署方法及系统 |
| CN110275775A (zh) * | 2019-05-17 | 2019-09-24 | 平安科技(深圳)有限公司 | 容器应用的资源配置方法、系统及存储介质 |
| CN111324421A (zh) * | 2020-02-18 | 2020-06-23 | 支付宝(杭州)信息技术有限公司 | 一种容器镜像的提供方法、加载方法及相关设备和系统 |
Family Cites Families (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US9934073B2 (en) * | 2015-10-23 | 2018-04-03 | Futurewei Technologies, Inc. | Extension of resource constraints for service-defined containers |
| CN107766130B (zh) * | 2016-08-22 | 2020-11-24 | 中国电信股份有限公司 | 虚拟机向容器迁移的方法和装置 |
| CN107819802B (zh) * | 2016-09-13 | 2021-02-26 | 华为技术有限公司 | 一种在节点集群中的镜像获取方法、节点设备及服务器 |
| US10922118B2 (en) * | 2018-05-11 | 2021-02-16 | International Business Machines Corporation | Distributed container image repository service |
| CN110263546B (zh) * | 2019-05-24 | 2023-05-05 | 创新先进技术有限公司 | 一种对容器镜像进行安全检查的方法、装置以及设备 |
-
2020
- 2020-02-18 CN CN202010097850.3A patent/CN111324421B/zh active Active
- 2020-11-30 WO PCT/CN2020/132681 patent/WO2021164367A1/zh not_active Ceased
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20170054759A1 (en) * | 2015-08-19 | 2017-02-23 | Samsung Sds Co., Ltd. | Method and apparatus for security checking of image for container |
| CN109634657A (zh) * | 2018-12-14 | 2019-04-16 | 武汉烽火信息集成技术有限公司 | 一种微服务打包部署方法及系统 |
| CN110275775A (zh) * | 2019-05-17 | 2019-09-24 | 平安科技(深圳)有限公司 | 容器应用的资源配置方法、系统及存储介质 |
| CN111324421A (zh) * | 2020-02-18 | 2020-06-23 | 支付宝(杭州)信息技术有限公司 | 一种容器镜像的提供方法、加载方法及相关设备和系统 |
Cited By (13)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114237686A (zh) * | 2021-11-19 | 2022-03-25 | 北京百度网讯科技有限公司 | 安装包生成方法、装置、电子设备及存储介质 |
| CN114090183A (zh) * | 2021-11-25 | 2022-02-25 | 北京字节跳动网络技术有限公司 | 一种应用启动方法、装置、计算机设备和存储介质 |
| CN114090183B (zh) * | 2021-11-25 | 2023-07-21 | 抖音视界有限公司 | 一种应用启动方法、装置、计算机设备和存储介质 |
| CN114237760B (zh) * | 2021-12-21 | 2023-08-11 | 华北电力大学 | 一种将工业机理模型封装为容器镜像并发布web服务的方法 |
| CN114237760A (zh) * | 2021-12-21 | 2022-03-25 | 华北电力大学 | 一种将工业机理模型封装为容器镜像并发布web服务的方法 |
| CN113946799A (zh) * | 2021-12-21 | 2022-01-18 | 深圳佑驾创新科技有限公司 | 应用程序源码保护方法以及服务端 |
| CN114595034A (zh) * | 2022-03-07 | 2022-06-07 | 中南大学 | 一种容器镜像体积缩小方法、存储器及装置 |
| CN114697313A (zh) * | 2022-03-15 | 2022-07-01 | 浪潮云信息技术股份公司 | 一种基于镜像的文件下载方法 |
| CN115658238A (zh) * | 2022-11-10 | 2023-01-31 | 深圳开源互联网安全技术有限公司 | 容器镜像下载方法、装置、终端设备以及存储介质 |
| CN116954831A (zh) * | 2023-09-20 | 2023-10-27 | 中国电子科技集团公司第十五研究所 | 基于装配文件生成容器镜像包的方法及系统 |
| CN116954831B (zh) * | 2023-09-20 | 2023-11-28 | 中国电子科技集团公司第十五研究所 | 基于装配文件生成容器镜像包的方法及系统 |
| CN119004464A (zh) * | 2024-08-21 | 2024-11-22 | 北京火山引擎科技有限公司 | 容器镜像中恶意文件的检测方法、装置、介质、设备及产品 |
| CN119442248A (zh) * | 2024-10-22 | 2025-02-14 | 上海交通大学 | 恶意容器镜像的威胁评估与多维度检测系统及方法 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN111324421A (zh) | 2020-06-23 |
| CN111324421B (zh) | 2023-04-07 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN111324421B (zh) | 一种容器镜像的提供方法、加载方法及相关设备和系统 | |
| US10162624B1 (en) | Web shell for dynamically generated cross-platform applications | |
| US9942307B2 (en) | Web application script migration | |
| US20100205604A1 (en) | Systems and methods for efficiently running multiple instances of multiple applications | |
| JP6182160B2 (ja) | 実行中のプロセスへのコードの動的挿入 | |
| CN114020621B (zh) | 一种调试方法、电子设备及存储介质 | |
| AU2016202576B2 (en) | Techniques for evaluating applications through use of an auxiliary application | |
| US20250278290A1 (en) | Container hot migration method and container hot migration apparatus | |
| CN114721659A (zh) | 函数服务处理方法、装置及电子设备 | |
| CN110020370A (zh) | 在客户端应用中实现动画的方法、装置及动画脚本的框架 | |
| CN112154417B (zh) | 经由仿真网络通信信道在应用的单机版本和基于Web的版本之间共享代码库 | |
| CN112395096A (zh) | 远程函数调用的处理方法、装置、电子设备及存储介质 | |
| CN115640005A (zh) | 混合应用的生成方法及装置 | |
| CN114254232B (zh) | 云产品页面生成方法、装置、计算机设备和存储介质 | |
| US11960861B1 (en) | System and method for code development tools existing within code container | |
| CN115129417A (zh) | 基于Kubernetes平台的虚拟机创建方法、装置及存储介质 | |
| CN115718588A (zh) | 发布网络服务的方法、装置、存储介质及处理器 | |
| CN116467049A (zh) | 微服务的容器镜像构建方法、装置、系统、设备及介质 | |
| CN118012518A (zh) | 应用程序启动方法、装置、计算机设备及存储介质 | |
| CN114880073A (zh) | 一种对用户屏蔽Web框架的云应用引擎部署方法、装置、设备和存储介质 | |
| CN119987793B (zh) | 云渲染包部署方法、远程服务器、客户端及存储介质 | |
| WO2022078057A1 (zh) | 应用包发布方法、应用方法、装置、介质、服务器及设备 | |
| CN117234545B (zh) | 应用程序安装方法、装置、终端设备以及存储介质 | |
| WO2026056620A1 (zh) | 内核模块处理方法、设备、存储介质及程序产品 | |
| CN115309471A (zh) | 一种应用程序启动方法、装置、设备及介质 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 20920053 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 20920053 Country of ref document: EP Kind code of ref document: A1 |