Inter-container communication method, host machine, medium, and program product
By sharing the physical network card's IP address and port number with the host machine, and using the RDMA protocol for inter-container communication, the problem of poor data transmission stability between containers is solved, and more stable data transmission is achieved.
Patent Information
- Application Number
- PCT/IB2025/052979
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-05-31
- Filing Date
- 2025-03-21
- Publication Date
- 2025-12-04
Smart Images

Figure IB2025052979_04122025_PF_FP_ABST
Abstract
Description
[0001] This disclosure claims priority to Chinese Patent Application No. 202410705525.9, filed on May 31, 2024, entitled "Inter-container Communication Method, Host Machine, Media, and Program Product," the entire contents of which are incorporated herein by reference. Technical Field This disclosure relates to the field of cloud computing technology, and more particularly to an inter-container communication method, host machine, media, and program product. Background Art The use of the Remote Direct Memory Access (RDMA) protocol allows a local device to "directly" access the memory of a remote device. Here, "directly" means that data in the remote device can be read and written directly, just like accessing local memory. Since the data read and write process bypasses the central processing unit (CPU) of both devices, data transmission latency can be greatly reduced. Furthermore, in practice, the aforementioned RDMA protocol can also be used to achieve inter-container communication for containers running on the host machine. The use of this protocol can also reduce the data transmission latency between containers. Based on the above description, improving the stability of data transmission during communication becomes a pressing issue for containers communicating via the RDMA protocol. In view of this, the present disclosure provides an inter-container communication method, a host machine, a medium, and a program product to improve the stability of data transmission via the RDMA protocol. In a first aspect, the present disclosure provides an inter-container communication method applied to a first container, comprising: sending a first pending request, wherein the first container and a second container respectively share the port number of the host machine and the Internet Protocol address of the physical network interface card (NIC) in the host machine with the host machine; the first pending request includes the Internet Protocol address of the physical NIC in the host machine and the port number corresponding to the first container; receiving a first response result of the first pending request, wherein the first response result is sent by the second container according to the Internet Protocol address of the host machine and the port number corresponding to the first container; the first pending request and the first response result are transmitted via RDMA protocol through remote memory access.Secondly, embodiments of this disclosure provide an inter-container communication method applied to a first container, comprising: sending a pending request, wherein the pending request includes an Internet Protocol address and a port number corresponding to the first container, the Internet Protocol address including an Internet Protocol address of the host machine or an Internet Protocol address of a virtual network interface card bound to the first container, the port number including a port number of the host machine or a port number of the virtual network interface card bound to the first container, the Internet Protocol address and port number of the virtual network interface card being determined when the first container starts; receiving a response result of the pending request, the response result being sent by a second container according to the Internet Protocol address of the virtual network interface card and the virtual network interface card, the pending request and the response result being transmitted via remote memory direct access RDMA protocol and / or Transmission Control Protocol TCP transmission. Thirdly, embodiments of this disclosure provide a host machine, including: a memory and a processor, and a first container and a second container running in an isolated environment constructed by the memory and the processor, wherein the first container and the second container share the port number of the host machine and the Internet Protocol address of the physical network interface card in the host machine with the host machine, respectively; the first container is configured to send a first pending request, the first pending request including the Internet Protocol address of the physical network interface card in the host machine and the port number corresponding to the first container; and receive a first response result sent by the second container; the second container is configured to respond to the first pending request to generate the first response result; and send the first response result according to the Internet Protocol address of the physical network interface card in the host machine and the port number corresponding to the first container, wherein the first pending request and the first response result are transmitted via Remote Memory Direct Access (RDMA) protocol.Fourthly, embodiments of this disclosure provide a host machine, a memory, and a processor, as well as a first container and a second container running in an isolated environment constructed by the memory and the processor; the first container is configured to send a pending request, wherein the pending request includes an Internet Protocol address and a port number corresponding to the first container, the Internet Protocol address including an Internet Protocol address of the host machine or an Internet Protocol address of a virtual network interface card bound to the first container, the port number including a port number of the host machine or a port number of the virtual network interface card bound to the first container, the Internet Protocol address and port number of the virtual network interface card being determined when the first container starts; the second container is configured to respond to the pending request to generate the response result; the response result is sent according to the Internet Protocol address of the virtual network interface card and the virtual network interface card, the pending request and the response result being transmitted via remote memory directly using RDMA protocol transmission and / or Transmission Control Protocol TCP transmission. Fifthly, embodiments of this disclosure provide a host machine, including: a memory for storing one or more computer instructions, wherein the one or more computer instructions, when executed by the processor, implement the inter-container communication method described in the first or second aspect. The host machine may further include a communication interface for communicating with other devices or communication systems. Sixthly, embodiments of this disclosure provide a non-transitory machine-readable storage medium storing executable code, which, when executed by a processor of a non-transitory machine, enables the processor to at least implement the inter-container communication method described in the first or second aspect. Seventhly, embodiments of this disclosure provide a computer program product. The computer program product includes a computer program or instructions, which, when executed by a processor, cause the processor to implement the inter-container communication method described in the first or second aspect. The inter-container communication method provided in this embodiment involves a first container and a second container running on a host machine. The first and second containers share the host machine's port number and the Internet Protocol address (IP address) of the physical network interface card (NIC). Specifically, no IP address is assigned to the container during container creation, nor is a virtual NIC created for it. The first and second containers can then communicate as follows: The first container sends a first pending request that requires transmission via the RDMA protocol. This request may include the IP address of the physical NIC in the host machine and the port number corresponding to the first container.After receiving the first pending request, the second container responds to it to obtain a first response result. This first response result is also transmitted using the RDMA protocol. This first response result can then be fed back to the first container according to the host machine's IP address and the port number corresponding to the first container, thus completing communication between the two containers. In the above method, for containers sharing an Internet Protocol address and port number that need to communicate using the RDMA protocol, communication can be achieved directly using the IP address of the physical network card shared with the host machine. The host machine's IP address often has better network communication performance, thus improving the stability of data transmission under the RDMA protocol. Brief Description of the Drawings: To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Figure 1 is a flowchart of an inter-container communication method provided in an embodiment of this disclosure; Figure 2 is a flowchart of another inter-container communication method provided in an embodiment of this disclosure; Figure 3 is a flowchart of yet another inter-container communication method provided in an embodiment of this disclosure; Figure 4 is a flowchart of yet another inter-container communication method provided in an embodiment of this disclosure; Figure 5 is a schematic diagram of the structure of a host machine provided in an embodiment of this disclosure; Figure 6 is a schematic diagram of the structure of another host machine provided in an embodiment of this disclosure; Figure 7 is a schematic diagram of the structure of yet another host machine provided in an embodiment of this disclosure; Figure 8 is a schematic diagram of the structure of an inter-container communication device provided in an embodiment of this disclosure; Figure 9 is a schematic diagram of the structure of another inter-container communication device provided in an embodiment of this disclosure; Figure 10 is a schematic diagram of the structure of yet another host machine provided in an embodiment of this disclosure; Figure 11 is a schematic diagram of the structure of yet another host machine provided in an embodiment of this disclosure. Specifically, to make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments in this disclosure, all other embodiments obtained by those skilled in the art without inventive effort are within the scope of protection of this disclosure. The terminology used in the embodiments of this disclosure is for the purpose of describing particular embodiments only and is not intended to limit this disclosure.The singular forms “a,” “the,” and “the” used in this disclosure and the appended claims are also intended to include the plural forms. Unless the context clearly indicates otherwise, “multiple” generally includes at least two, but does not exclude the inclusion of at least one. It should be understood that the term “and / or” as used herein is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone. Additionally, the character “ / ” in this document generally indicates that the preceding and following related objects are in an “or” relationship. Depending on the context, the words “if” and “suppose” as used herein can be interpreted as “when,” “in response to determination,” or “in response to identification.” Similarly, depending on the context, the phrases "if determined" or "if identified (the stated condition or event)" can be interpreted as "when determined" or "in response to determined" or "when identified (the stated condition or event)" or "in response to identified (the stated condition or event)". It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse. It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a product or system comprising a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a product or system. Without further limitations, an element defined by the phrase "including one..." does not exclude the presence of other identical elements in the product or system that includes said element. Before describing the methods and host provided in the following embodiments of this disclosure, the following concepts can also be explained: Host: A physical host on which container orchestration tools are installed. At least one container may also run on the host. The host has its own operating system and hardware resources, and is the basis for the operation of the container orchestration tools. Containers running on the host can be created, run, and monitored through container orchestration tools. Container: A lightweight package running on the host.Containers share the kernel with the host operating system, but have their own runtime environment and file system, etc. Containers are isolated from each other, meaning process-level isolation is achieved. Inter-container communication refers to the data transfer process between containers running on the same or different host machines. Data between containers can be transferred using RDMA or Transmission Control Protocol (TCP).
[0002] RDMA protocol: A transport protocol developed to reduce latency in data transmission. As mentioned in the background section, this protocol allows local devices to directly read and write data on remote devices as if accessing local memory. Because the data read and write process bypasses the CPUs of both devices, it can significantly reduce data transmission latency.
[0003] TCP Protocol: A full-duplex, connection-oriented, byte-stream-based transport layer communication protocol. This protocol provides reliable end-to-end byte-stream transmission services for different communication devices in interconnected communication networks. Based on the above description, some embodiments of this disclosure will be described in detail below with reference to the accompanying drawings. Where there is no conflict between the embodiments, the following embodiments and features can be combined with each other. Furthermore, the timing of the steps in the following method embodiments is merely an example and not a strict limitation. Figure 1 is a flowchart of an inter-container communication method provided by an embodiment of this disclosure. The method provided by this disclosure can be executed by a first container running on a host machine. As shown in Figure 1, the method may include the following steps:
[0004] 5101, Send a first pending request, wherein the first container and the second container share the port number of the host machine and the Internet Protocol address of the physical network card in the host machine with the host machine respectively, and the first pending request includes the Internet Protocol address of the physical network card in the host machine and the port number corresponding to the first container.
[0005] 5102. Receive the first response result of the first pending request. The first response result is sent by the second container according to the host machine's Internet Protocol address and the port number corresponding to the first container. The first pending request and the first response result are transmitted using the RDMA protocol. The host machine can run multiple containers and container orchestration tools for managing the containers. Containers on the host machine can be created by the container orchestration tool. Optionally, the container orchestration tool can include any of Kubernetes (K8S), Docker Swarm, Apache Mesos, etc. Since the containers created by the container orchestration tool share the host machine's Internet Protocol Address (IP address) and port number with the host machine providing the runtime environment, optionally, when a container is created, the container orchestration tool may not create its own virtual network interface card (NIC) or configure its own IP address for the container. Different containers can then communicate using the IP address of the physical NIC on the host machine and the port number corresponding to the container, which are shared between themselves and the host machine. Optionally, the container orchestration tool's method of not creating a corresponding virtual network interface card (NIC) or assigning an IP address to the container after it starts can also be considered as the process of the container orchestration tool creating a container in the host machine's host mode. Optionally, the port number corresponding to the container can be assigned during creation; the specific allocation method can be found in the relevant descriptions in the embodiments shown in Figure 2 or Figure 3 below. For the first and second containers that share IP addresses and port numbers with the host machine and need to communicate, the specific communication process can include: The first container can generate a first pending request. This first pending request can be a request that needs to be transmitted using the RDMA protocol, i.e., RDMA data. The first pending request can include the respective IP addresses and corresponding port numbers of the first and second containers. The first container can then further send this first pending request according to the IP address and port number of the second container. Since the first and second containers are created in host mode, they can have the same IP address but different port numbers. After receiving the first pending request, the second container can respond to it to obtain a first response result. Similar to the first pending request, the first response result also needs to be transmitted using the RDMA protocol, and this response result is also RDMA data.Furthermore, the first response result may also include the IP addresses and corresponding port numbers of the first and second containers, respectively. Finally, the second container can send the first response result back to the first container using the IP address and port number of the first container. Upon receiving the first response result, the communication between the containers regarding the first pending request is complete. Optionally, pending requests requiring RDMA protocol transmission can also be generated by the second container. In this case, the second container can send the request in the manner described above, and the first container can respond and provide feedback in the manner described above. In this embodiment, the host machine runs both the first and second containers, and the containers share the IP address and port number of the host machine. The first and second containers can then communicate as follows: The first container sends a first pending request requiring RDMA protocol transmission. This request may include the IP address of the physical network card in the host machine and the port number corresponding to the first container. After receiving the first pending request, the second container responds to it to obtain a first response result. The first response result also requires RDMA protocol transmission. The first response result can then be fed back to the first container according to the host machine's IP address and the port number corresponding to the first container, thus completing the communication between the two containers. In the above method, for containers that share IP addresses and port numbers and communicate using the RDMA protocol, the IP address of the physical network card in the host machine can be used directly for communication. The fixed IP address of the host machine often has better network communication performance, thus improving the stability of data transmission under the RDMA protocol. Optionally, the host machine mentioned in this embodiment and the following method embodiments can specifically be a device deployed in a distributed storage system. A host machine running containers is also a containerized host machine, and further, a containerized host machine can constitute a containerized distributed storage system. Optionally, a distributed storage system can be, for example, a Pangu system for cloud computing, etc. Containerization of a distributed storage system can provide an isolated environment, avoiding conflicts and interference between containers. Secondly, containerization can also enable rapid deployment and elastic expansion of the system, improving the system's flexibility and scalability. In addition, containerization can simplify the management and maintenance process of hardware devices in the system, reducing the system's operation and maintenance costs. Building upon the advantages described above, the method provided in this disclosure can also improve the stability of RDMA data transmission in distributed storage systems.Furthermore, as described in the embodiment shown in Figure 1, the sending and receiving of the first request to be processed and the first response result require the use of the IP address of the first container and the port number corresponding to the first container. For the first container that shares its IP address and port number with the host machine, that is, the IP address of the container is the IP address of the host machine, and the port number corresponding to the container can be obtained using different allocation methods. Optionally, the port number can be allocated by the container orchestration tool when the container is created. The container orchestration tool can allocate any unused port number in the host machine to the first container. For this allocation method, the communication process between containers can be referred to the description in the embodiment shown in Figure 2. Figure 2 is a flowchart of another inter-container communication method provided by an embodiment of this disclosure. As shown in Figure 2, the method may include the following steps:
[0006] 5201, Send the first pending request. The first pending request includes the IP address of the physical network card in the host machine and the first port number of the first container. The first port number is assigned when the first container is created.
[0007] 5202, Receive the first response result of the first pending request. The first response result is sent by the second container according to the IP address of the physical network card in the host machine and the first port number of the first container. The first pending request and the first response result are transmitted using the RDMA protocol. The container orchestration tool can assign a port number to the container when creating the container. It is easy to understand that the container orchestration tool can assign any unused port number in the host machine to the container. That is to say, in this embodiment, the container orchestration tool assigns the host machine's host port to the container. After the container is created, the container will have its own IP address and its own first port number. At this time, the first pending request generated by the first container can include the IP addresses and first port numbers of the first and second containers respectively. After the first pending request is forwarded to the second container, the second container can respond and generate a first response result, and feed the result back to the first container. The first response result can also include the IP addresses and corresponding first port numbers of the first and second containers respectively. The specific communication process between the first container and the second container can be referred to the relevant description in the embodiment shown in Figure 1, and will not be repeated here. In this embodiment, the first port number corresponding to the container can be an unused port number on the host machine, assigned by the container orchestration tool when the container is created. In this case, containers can directly communicate using the IP address and port number of the physical network card on the host machine. Since the host machine's IP address and port are fixed, and communication using the host machine's address usually has better network performance, the stability of RDMA data transmission can be improved. Furthermore, the contents not described in detail in this embodiment and the technical effects that can be achieved can be found in the relevant descriptions in the above embodiments, and will not be repeated here. In practice, the same container can generate multiple pending requests that need to be transmitted using different protocols, such as RDMA or TCP mentioned above. Pending requests that need to be transmitted using different protocols obviously cannot be transmitted using the same port. That is, if the same port is used to transmit pending requests corresponding to different protocols, port conflicts can easily occur, which can ultimately lead to communication chaos between containers. To mitigate the aforementioned port conflict issue, another alternative allocation method involves, after assigning a first port number to the container, the mapping module located in the host kernel further utilizing a pre-configured port configuration file to map the first port to a second port number. The second port can be another unused host port on the host machine.For this allocation method, the communication process between containers can be referred to the description in the embodiment shown in Figure 3. Figure 3 is a flowchart of another inter-container communication method provided by this disclosure. As shown in Figure 3, the method may include the following steps:
[0008] 5301, Send the first pending request. The first pending request includes the IP address of the physical network card in the host machine and the second port number of the first container. The second port number is obtained by mapping the first port number of the first container according to the port configuration file. The first port number is assigned when the first container is created.
[0009] 5302, Receive the first response result of the first pending request. The first response result is sent by the second container according to the IP address of the physical network card in the host machine and the second port number of the first container. The first pending request and the first response result are transmitted using the RDMA protocol. The container orchestration tool can assign the first port number to the container during the container creation process. The specific allocation process of the first port number can be found in the relevant description in the embodiment shown in Figure 2, and will not be repeated here. Furthermore, the mapping module running in the host kernel can further perform port mapping on the container according to the pre-set port configuration file. The port configuration file can record the preset correspondence between the first port number and at least one second port number of different containers. The port mapping can improve the port conflict problem mentioned above. And the first port number and the second port number of the same container both belong to the host port O of the host machine. After the above port mapping, the first pending request generated by the first container can include the IP address of the first container and the second port number obtained after the mapping of the first container. After the first pending request is sent to the second container, the second container can generate a first response result and send this result back to the first container according to the first container's IP address and second port number. This completes the inter-container communication for the first pending request. The first response result may also include the first container's IP address and second port number. More specifically, the first response result can first be sent by the second container to a mapping module in the host kernel. This module can further map the second port number of the first container in the first response result back to the first port number of the first container according to the port configuration file. The mapping module then sends the first response result back to the first container according to the first port number. For details not described in the inter-container communication process, please refer to the relevant descriptions in the embodiment shown in Figure 1, which will not be repeated here. In this embodiment, based on the port allocation by the container orchestration tool, port mapping can be further performed. This port mapping process can improve the port conflict problem, thereby ensuring normal inter-container communication. Furthermore, for details not described in this embodiment and the technical effects achieved, please refer to the relevant descriptions in the above embodiments, which will not be repeated here. As shown in the embodiment of Figure 3, the same container can generate multiple pending requests that require transmission using different protocols. Specifically, in addition to the first pending request that requires transmission using the RDMA protocol, the first container can optionally generate a second pending request that requires transmission using the TCP protocol, i.e., TCP data.Furthermore, the second pending request may include the IP address and port number of the virtual network interface card (NIC) bound to the first container, and may also include the IP address and port number of the virtual NIC bound to the second container. Optionally, the virtual NIC may specifically be a dummy NIC. To achieve normal TCP data transmission, the second pending request may optionally be sent to the second container according to the IP address and port number of the virtual NIC bound to the second container. After responding to this second pending request, the second container generates a second response result. Optionally, this second response result is also TCP data, meaning it also needs to be transmitted using the TCP protocol. The second response result may also include the IP address and port number of the virtual NIC bound to the first container, as well as the IP address and port number of the virtual NIC bound to the second container. Then, the second container can send the second response result back to the first container according to the IP address and port number of the virtual NIC bound to the first container. This completes the communication between containers for the second pending transmission request. In this embodiment, for containers that share IP addresses and port numbers with the host, a virtual network interface card (NIC) created by the container orchestration tool can be used to achieve normal TCP data transmission. Optionally, the virtual NIC bound to the container mentioned in the above embodiments can be created by the container orchestration tool when the container starts. Optionally, the container orchestration tool can also assign an IP address to the created virtual NIC according to a pre-configured address configuration file. Furthermore, the IP address of the virtual NIC is different from the host machine's IP address, and the port number of the virtual NIC is also different from the host machine's port number; that is, the port number assigned to the virtual NIC by the container orchestration tool is different from the first port number assigned to the container. It should be noted that when the container does not generate TCP data, the container orchestration tool will not create a virtual NIC for the container, and the containers can achieve inter-container communication for RDMA data as shown in the embodiments of Figures 1-3. When a container can generate both RDMA and TCP data, as described in the above embodiments, one alternative approach is to use the host machine's physical network interface card (NIC) to achieve normal TDMA data transmission between containers, or to use a virtual NIC to achieve normal TCP data transmission between containers. Furthermore, since the IP address and port number of the virtual NIC used for transmitting TCP data are different from those of the physical NIC used for transmitting TDMA data, users can clearly understand the different IP addresses used for transmitting different types of data, thus providing a better user experience.Optionally, pending requests requiring TCP protocol transmission can also be generated by the second container. The second container can then send the request in the manner described above, and the first container can respond and provide feedback in the same manner. In this embodiment, different IP addresses and port numbers are used during the transmission of RDMA data and TCP data, thus providing a better user experience. When a container can generate both RDMA and TCP data, another optional method is to utilize a virtual network interface card (NIC) to simultaneously achieve normal transmission of TDMA and TCP data between containers. The process of transmitting TCP and RDMA data using a virtual NIC can be seen in the embodiment shown in Figure 4 below. Figure 4 is a flowchart of another inter-container communication method provided by this disclosure embodiment. The method provided by this disclosure embodiment can be executed by a first container running on the host machine. As shown in Figure 4, the method may include the following steps:
[0010] 5401, Send a pending request, wherein the pending request contains the Internet Protocol address and port number corresponding to the first container, the Internet Protocol address in the pending request includes the Internet Protocol address of the host machine or the Internet Protocol address of the virtual network interface card bound to the first container, the port number in the pending request includes the port number of the host machine or the port number of the virtual network interface card bound to the first container, and the Internet Protocol address and port number of the virtual network interface card are determined when the first container starts.
[0011] 5402, Receive the response result of the pending request. The response result is sent by the second container according to the Internet Protocol address of the virtual network interface card (NIC) and the virtual NIC. The pending request and the response result are transmitted using RDMA protocol and / or TCP. When a container sharing an IP address and port number with the host machine is created, the container orchestration tool may not assign an IP address to the container or create a corresponding virtual NIC. However, after the container starts, the container orchestration tool can create a virtual NIC and assign its IP address and port number. The aforementioned container can also be considered as created in the host mode of the host machine, and the relevant content regarding container creation, virtual NIC creation, and address allocation can be found in the relevant descriptions in the above embodiments, and will not be repeated here. For the first container and the second container, the communication process between them may include: the first container can generate a pending request. This pending request can be the first pending request and / or the second pending request mentioned in the above embodiments; that is, the first pending request needs to be transmitted using RDMA protocol, and the second pending request needs to be transmitted using TCP protocol. Since the pending request can include the IP address and port number of the virtual network interface card (NIC) bound to both the data sender and receiver, it can be sent to the second container using the IP address and port number of the NIC bound to the second container. Upon receiving the pending request, the second container can respond to it to obtain a response result. This response result can also include the IP address and port number of the virtual NIC bound to both the data sender and receiver. Specifically, when the pending request is the first pending request in the above embodiment, the response result here is the first response result in the above embodiment, which needs to be transmitted using the RDMA protocol. Similarly, when the pending request is the second pending request in the above embodiment, the response result here is the second response result in the above embodiment, which needs to be transmitted using the TCP protocol. Furthermore, the second container can send the response result back to the first container using the IP address and port number of the virtual NIC bound to the first container. Once the first container receives the first response result, the inter-container communication is complete. Optionally, the request to be processed can also be generated by the second container. In this case, the second container can also send the request in the manner described above, and the first container can also respond to and provide feedback on the request in the manner described above. In this embodiment, the first container and the second container run on the host machine, and both are created in the host mode of the host machine. Additionally, the container orchestration tool can create a virtual network interface card for the container when it starts up.The pending requests generated by the first container can be transmitted to the second container using the virtual network interface card (NIC), thereby achieving inter-container communication. As can be seen from the above embodiments, the virtual NIC is necessary for the transmission of TCP data between containers. This embodiment actually reuses the virtual NIC bound to the container to achieve the transmission of RDMA data between containers. The reuse of the virtual NIC simplifies the inter-container communication process. Furthermore, the content not described in detail in this embodiment and the technical effects that can be achieved can be found in the relevant descriptions of the above embodiments, and will not be repeated here. The process of inter-container communication has been described from a methodological perspective. Since the containers are deployed on a host machine, the host machine structure can be described in detail below. Figure 5 is a schematic diagram of the structure of a host machine provided by an embodiment of this disclosure. As shown in Figure 5, the host machine may include: a memory and a processor, and a first container and a second container running in an isolated environment constructed by the memory and processor. The first container and the second container share the port number of the host machine and the IP address of the physical NIC in the host machine, respectively. That is, the first container and the second container are created in the host mode of the host machine. The communication process between the first container and the second container can be described as follows: The first container can generate a first pending request. This first pending request may be a request that needs to be transmitted using the RDMA protocol. The first container can further send the first pending request according to the IP address of the second container and the port number corresponding to the second container contained in the first pending request. After receiving the first pending request, the second container can respond to it to obtain a first response result. Similar to the first pending request, the first response result also needs to be transmitted using the RDMA protocol. Further, the second container can send the first response result back to the first container according to the IP address of the first container and the port number corresponding to the first container. After the first container receives the first response result, the communication between the containers for the first pending request is completed. And since the first container and the second container are created in host mode, the first container and the second container can have the same IP address, but can have different port numbers. Optionally, the pending request that needs to be transmitted using the RDMA protocol can also be generated by the second container, then the second container can also send the request in the above manner, and the first container can also respond to and send the request in the above manner. In this embodiment, with the help of the hardware provided by the host machine, the first container and the second container can run in an isolated environment provided by the host machine.For containers that share an IP address and port number with the host machine, communication can be achieved as follows: The first container sends a first pending request. After receiving the first pending request, the second container responds to it to obtain a first response result. This first response result can then be fed back to the first container according to the host machine's IP address and the port number corresponding to the first container. At this point, communication between the two containers is completed. Both the first pending request and the first response result are transmitted using the RDMA protocol. In the above method, for containers that share an IP address and port number with the host machine, the IP address of the physical network card in the host machine can be directly used to achieve communication for RDMA data. Furthermore, the fixed IP address of the host machine often has better network communication performance, thus improving the stability of data transmission under the RDMA protocol. Optionally, the host machine provided in the embodiments of this disclosure is deployed in a distributed storage system. Figure 6 is a schematic diagram of another host machine structure provided in an embodiment of this disclosure. Based on the host machine shown in Figure 5, optionally, a container orchestration tool also runs in the host machine. The container orchestration tool can assign port numbers to containers when creating them. It is easy to understand that since the created container shares the host machine's IP address and port number with the host machine, meaning the container is created in host mode, the container orchestration tool can assign any unused port number on the host machine to the container. In other words, in this embodiment, the container orchestration tool assigns the host machine's host port to the container. After the container is created, it has its own IP address and its own first port number, which is the port number corresponding to the first container in the embodiment shown in Figure 5. At this time, the first pending request generated by the first container can be sent according to the IP address and first port number of each of the second containers. After the first pending request is forwarded to the second container, the second container can respond and generate a first response result, and then send the result back to the first container. The specific communication process between the first and second containers can be found in the relevant description in the embodiment shown in Figure 5, and will not be repeated here. In this embodiment, the container's first port number can be an unused port number on the host machine assigned to it by the container orchestration tool when the container is created. In this scenario, containers can communicate directly using the IP address and port number of the physical network interface card (NIC) on the host machine. Furthermore, the fixed IP address of the host machine often offers good network communication performance, thus improving the stability of data transmission under the RDMA protocol.The embodiment shown in Figure 3 mentions a port conflict issue. To improve this, optionally, after assigning a first port number to the container, the mapping module running in the host kernel can further map the first port to a second port number according to a pre-configured port configuration file. The container orchestration tool can assign the first port number to the container during container creation. The specific allocation process of the first port number can be found in the relevant description in the embodiment shown in Figure 2, and will not be repeated here. Furthermore, both the first port number before mapping and the second port number after mapping for the same container can belong to the host machine's host port. After port mapping according to the pre-configured port configuration file in the mapping module, the first pending request generated by the first container can include the IP address of the first container and the second port number obtained after mapping. After the first pending request is sent to the second container, the second container can generate a first response result. Then, the first response result can be fed back by the second container to the mapping module in the host kernel. This module can further map the second port number of the first container in the first response result back to the first port number of the first container according to the port configuration file, and the mapping module then feeds back the first response result to the first container according to the first port number. This completes the communication between containers for the first pending request. For details not described in the container communication process, please refer to the relevant descriptions in the embodiment shown in Figure 5, which will not be repeated here. In this embodiment, in addition to the port allocation by the container orchestration tool, port mapping can be further performed. This port mapping process can improve the port conflict problem, thereby ensuring the normal operation of inter-container communication. As described in the above embodiments, during the inter-container communication process, the first container can also generate TCP data, which is the second pending request. To achieve normal transmission of TCP data, optionally, the second pending request can be sent to the second container according to the IP address and port number of the virtual network interface card bound to the second container. After the second container responds to this second pending request, it generates a second response result. Optionally, this second response result is also TCP data, that is, it also needs to be transmitted using the TCP protocol. Furthermore, the second response result can also include the IP address and port number of the virtual network interface card bound to the first container, as well as the IP address and port number of the virtual network interface card bound to the second container. The second container can then send the second response back to the first container using the IP address and port number of the virtual network interface card bound to the first container. This completes the communication between containers for the second request to be transmitted.Optionally, pending requests requiring TCP protocol transmission can also be generated by the second container. The second container can then send the request in the manner described above, and the first container can respond to and provide feedback on the request in the same way. In this embodiment, for containers created in host mode, a virtual network interface card (NIC) created by a container orchestration tool can be used to achieve normal TCP data transmission. Optionally, the virtual NIC bound to the container mentioned in the above embodiments can be created by the container orchestration tool when the container starts. Optionally, the container orchestration tool can also assign an IP address to the created virtual NIC according to a pre-configured address configuration file. Furthermore, the IP address of the virtual NIC is different from the host machine's IP address, and the port number of the virtual NIC is also different from the host machine's port number; that is, the port number assigned to the virtual NIC by the container orchestration tool is different from the first port number assigned to the container. It should be noted that when a container can generate both RDMA data and TCP data, as described in the above embodiments, one optional method is to use the host machine's physical network card to achieve normal TDMA data transmission between containers, or a virtual network card to achieve normal TCP data transmission between containers. Furthermore, since the IP address and port number of the virtual network card used for transmitting TCP data are different from the IP address and port number of the physical network card used for transmitting TDMA data, users can clearly understand the different IP addresses used for transmitting different data, thus providing a good user experience. In this embodiment, different IP addresses and port numbers are used for transmitting RDMA data and TCP data respectively, thereby providing a good user experience. Figure 7 is a schematic diagram of another host machine structure provided by an embodiment of this disclosure. As shown in Figure 7, the host machine may include: a memory and a processor, and a first container and a second container running in an isolated environment constructed by the memory and processor. The first container sends a pending request, which may include the Internet Protocol address (IP address) and port number corresponding to the first container. The IIP address in the request may include the IP address of the host machine or the IP address of the virtual network interface card (NIC) bound to the first container. The port number in the request may include the port number of the host machine or the port number of the virtual NIC bound to the first container. The IP address and port number of the virtual NIC bound to the first container may be assigned by the container orchestration tool when the first container starts. More specifically, the pending request may include the IP address and port number of the host machine, or it may include the IP address and port number of the virtual NIC bound to the first container.Furthermore, the second container can respond to the aforementioned pending requests to generate a response result. Then, the response result is sent. When the pending request includes the host machine's IP address and port number, the pending request and response result are transmitted using RDMA protocol and / or TCP. When the pending request includes the virtual network interface card's IP address and port number, the pending request and response result are transmitted using TCP. Optionally, a container orchestration tool is also deployed on the host machine, and the virtual network interface card is created during container creation. Optionally, the pending request can also be generated by the second container, in which case the second container can also send the request in the above manner, and the first container can also respond to and provide feedback on the request in the above manner. In this embodiment, the host machine runs both a first container and a second container. Simultaneously, the container orchestration tool can create a virtual network interface card for the container when it starts. Therefore, all pending requests generated by the first container can be transmitted to the second container using this virtual network interface card, thereby achieving inter-container communication. Furthermore, this embodiment actually reuses the virtual network interface card bound to the container to realize the transmission of RDMA data between containers. The reuse of the virtual network interface card can simplify the processing flow of inter-container communication. In addition, the contents not described similarly in this embodiment can be referred to the relevant descriptions in the embodiment shown in Figure 4 above, and will not be repeated here. The following will describe in detail one or more embodiments of the inter-container communication device of this disclosure. Those skilled in the art will understand that these data query devices can all be configured using commercially available hardware components through the steps taught in this solution. Figure 8 is a structural schematic diagram of an inter-container communication device provided by an embodiment of this disclosure. As shown in Figure 8, the device may include: a first sending module 11, used to send a first request to be processed, wherein the first container and the second container respectively share the port number of the host machine and the Internet Protocol address of the physical network interface card in the host machine with the host machine, and the first request to be processed includes the Internet Protocol address of the physical network interface card in the host machine and the port number corresponding to the first container. The first receiving module 12 is configured to receive a first response result of the first pending request. The first response result is sent by the second container according to the Internet Protocol address of the host machine and the port number corresponding to the first container. The first pending request and the first response result are transmitted via Remote Memory Access (RDMA) protocol. Optionally, the first sending module 11 is configured to send the first pending request. The first pending request includes the Internet Protocol address of the physical network card in the host machine and a first port number of the first container. The first port number is assigned when the first container is created.In this configuration, the first response result is sent by the second container according to the Internet Protocol address of the physical network interface card (NIC) in the host machine and the first port number. Optionally, the first sending module 11 is used to send the first pending request, which includes the Internet Protocol address of the physical NIC in the host machine and the second port number of the first container. The second port number is obtained by mapping the first port number of the first container according to a port configuration file, and the second port number is assigned when the first container is created. In this configuration, the first response result is sent by the second container according to the Internet Protocol address of the physical NIC in the host machine and the second port number. Optionally, the first sending module 11 is used to send a second pending request, which includes the Internet Protocol address of a virtual NIC bound to the first container and the port number of the virtual NIC. The first receiving module 12 is used to receive the second response result of the second pending request. The second response result is sent by the second container according to the Internet Protocol address of the virtual NIC and the port number of the virtual NIC. The second pending request and the second response result are transmitted using Transmission Control Protocol (TCP). The virtual network interface card (NIC) bound to the first container is created when the first container starts. The Internet Protocol (IP) address of the virtual NIC is allocated according to an address configuration file. The IP address of the virtual NIC differs from the IP address of the physical NIC in the host machine, and the port number of the virtual NIC differs from the port number corresponding to the first container. The host machine is deployed in a distributed storage system. The device shown in Figure 8 can execute the method of the embodiment shown in Figures 1-3. For parts not described in detail in this embodiment, please refer to the relevant descriptions of the embodiments shown in Figures 1-3. The execution process and technical effects of this technical solution are described in the embodiments shown in Figures 4, and will not be repeated here. Figure 9 is a schematic diagram of another inter-container communication device provided in an embodiment of this disclosure. As shown in Figure 9, the device may include: a second sending module 21, used to send a request to be processed, wherein the request to be processed includes the Internet Protocol address and port number corresponding to the first container, the Internet Protocol address includes the Internet Protocol address of the host machine or the Internet Protocol address of the virtual network card bound to the first container, the port number includes the port number of the host machine or the port number of the virtual network card bound to the first container, and the Internet Protocol address and port number of the virtual network card are determined when the first container starts.The second receiving module 22 is used to receive the response result of the request to be processed. The response result is sent by the second container according to the Internet Protocol address of the virtual network card and the virtual network card. The request to be processed and the response result are transmitted via remote memory direct access RDMA protocol and / or Transmission Control Protocol TCP. The virtual network card bound to the first container is created when the first container starts. The Internet Protocol address of the virtual network card is allocated according to the address configuration file. The Internet Protocol address of the virtual network card is different from the Internet Protocol address of the physical network card in the host machine. The host machine is deployed in a distributed storage system. The device shown in Figure 9 can execute the method of the embodiment shown in Figure 4. For parts not described in detail in this embodiment, please refer to the relevant description of the embodiment shown in Figure 4. The execution process and technical effects of this technical solution are described in the embodiment shown in Figure 4, and will not be repeated here. In one possible design, the inter-container communication method provided in the above-mentioned embodiment of Figure 3 can be applied in a host machine, as shown in Figure 10. The host machine may include: a first processor 31 and a first memory 32. The first memory 32 stores programs that support the host machine in executing the inter-container communication methods provided in the embodiments shown in Figures 1-3. The first processor 31 is configured to execute the programs stored in the first memory 32. The programs include one or more computer instructions, which, when executed by the first processor 31, enable the following steps: sending a first pending request, wherein the first container and the second container share the port number of the host machine and the Internet Protocol address of the physical network interface card (NIC) in the host machine, respectively; the first pending request includes the NIC's NIC address and the port number corresponding to the first container; receiving a first response result of the first pending request, wherein the first response result is sent by the second container according to the host machine's NIC address and the port number corresponding to the first container; the first pending request and the first response result are transmitted via RDMA protocol through remote memory. Optionally, the first processor 31 is also used to execute all or part of the steps in the embodiments shown in Figures 1-3. The host machine may also include a first communication interface 33 for communication between the host machine and other devices or communication systems. In one possible design, the inter-container communication method provided in the embodiment of Figure 4 above can be applied to another host machine, as shown in Figure 11. The host machine may include: a second processor 41 and a second memory 42.The second memory 42 stores programs that support the host machine in executing the inter-container communication method provided in the embodiment shown in Figure 4. The second processor 41 is configured to execute the programs stored in the second memory 42. The programs include one or more computer instructions, which, when executed by the second processor 41, enable the following steps: sending a pending request, wherein the pending request includes the Internet Protocol address and port number corresponding to the first container, the Internet Protocol address including the Internet Protocol address of the host machine or the Internet Protocol address of the virtual network interface card bound to the first container, and the port number including the port number of the host machine or the port number of the virtual network interface card bound to the first container, the Internet Protocol address and port number of the virtual network interface card being determined when the first container starts; receiving a response result of the pending request, the response result being sent by the second container according to the Internet Protocol address of the virtual network interface card and the virtual network interface card, the pending request and the response result being transmitted via remote memory using RDMA protocol and / or Transmission Control Protocol TCP. Optionally, the second processor 41 is further configured to execute all or part of the steps in the embodiments shown in FIG. 4. The host machine may also include a second communication interface 43 for communication between the electronic device and other devices or communication systems. Additionally, embodiments of this disclosure provide a non-transitory machine storage medium for storing computer software instructions used by the aforementioned non-transitory machine, which includes programs for executing the inter-container communication methods shown in FIG. 1-4. Furthermore, embodiments of this disclosure provide a computer program product. This computer program product includes a computer program or instructions. When the computer program or instructions are executed by a processor, the processor is able to implement the steps or functions of the inter-container communication methods shown in FIG. 1-4. Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this disclosure and are not intended to limit it; although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure.
Claims
Claims 1. A method of inter-container communication, wherein, The method is applied to a first container and includes: sending a first pending request, wherein the first container and the second container share the port number of the host machine and the Internet Protocol address of the physical network interface card in the host machine with the host machine, respectively; the first pending request includes the Internet Protocol address of the physical network interface card in the host machine and the port number corresponding to the first container; receiving a first response result of the first pending request, wherein the first response result is sent by the second container according to the Internet Protocol address of the host machine and the port number corresponding to the first container; the first pending request and the first response result are transmitted via Remote Memory Access (RDMA) protocol.
2. The method of claim 1, wherein, Sending the first pending request includes: sending the first pending request, wherein the first pending request includes the Internet Protocol address of the physical network interface card in the host machine and the first port number of the first container, the first port number being assigned when the first container is created; wherein the first response result is sent by the second container according to the Internet Protocol address of the physical network interface card in the host machine and the first port number.
3. The method according to claim 1, wherein, Sending the first pending request includes: sending the first pending request, wherein the first pending request includes the Internet Protocol address of the physical network interface card in the host machine and the second port number of the first container, wherein the second port number is obtained by mapping the first port number of the first container according to the port configuration file, and the first port number is assigned when the first container is created; wherein the first response result is sent by the second container according to the Internet Protocol address of the physical network interface card in the host machine and the second port number.
4. The method according to any one of claims 1 to 3, wherein, The method further includes: sending a second pending request, the second pending request including the Internet Protocol address of the virtual network interface card bound to the first container and the port number of the virtual network interface card; receiving a second response result of the second pending request, the second response result being sent by the second container according to the Internet Protocol address of the virtual network interface card and the port number of the virtual network interface card, the second pending request and the second response result being transmitted using the Transmission Control Protocol (TCP).
5. The method according to claim 4, wherein, The virtual network interface card (NIC) bound to the first container is created when the first container starts; the Internet Protocol (IP) address of the virtual NIC is allocated according to the address configuration file; the IP address of the virtual NIC is different from the IP address of the physical NIC in the host machine, and the port number of the virtual NIC is different from the port number corresponding to the first container.
6. An inter-container communication method, wherein, Applied to a first container, the method includes: sending a pending request, wherein the pending request contains an Internet Protocol address (IPA) and a port number corresponding to the first container, the IPA address including an IPA of the host machine or an IPA of a virtual network interface card (NIC) bound to the first container, and the port number including a port number of the host machine or a port number of the virtual NIC bound to the first container, wherein the IPA address and port number of the virtual NIC are determined when the first container starts; and receiving a response result of the pending request, wherein the response result is processed by a second container according to the virtual NIC's... The Internet Protocol address and the virtual network card are sent, and the pending request and the response result are transmitted via RDMA protocol and / or Transmission Control Protocol TCP through remote memory direct access.
7. The method according to claim 6, wherein, The virtual network interface card (NIC) bound to the first container is created when the first container starts. The Internet Protocol (IP) address of the virtual NIC is allocated according to the address configuration file. The IP address of the virtual NIC is different from the IP address of the physical NIC in the host machine. The host machine is deployed in a distributed storage system.
8. A host machine, wherein, include: The system includes a memory and a processor, and a first container and a second container running in an isolated environment constructed by the memory and the processor, the first container and the second container sharing with the host machine a port number of the host machine and an Internet Protocol address of the physical network interface card in the host machine; the first container is configured to send a first pending request, the first pending request containing the Internet Protocol address of the physical network interface card in the host machine and the port number corresponding to the first container; and receive a first response result sent by the second container; the second container is configured to respond to the first pending request to generate the first response result. The first response result is sent according to the Internet Protocol address of the physical network card in the host machine and the port number corresponding to the first container. The first request to be processed and the first response result are transmitted via RDMA protocol through remote memory access.
9. The host machine of claim 8, wherein, It also runs a container orchestration tool, which, in response to the creation of the first container, assigns a first port number to the first container; the first container is used to send a first pending request containing the Internet Protocol address of the physical network interface card in the host machine and the first port number; the second container is used to send the first response result according to the Internet Protocol address of the physical network interface card in the host machine and the first port number.
10. The host machine of claim 8, wherein, It also runs a container orchestration tool, which, in response to the creation of the first container, assigns a first port number to the first container; maps the first port number of the first container to a second port number according to a port configuration file; the first container is used to send a first pending request containing the Internet Protocol address of the physical network interface card in the host machine and the second port number; the second container is used to send the first response result according to the Internet Protocol address of the physical network interface card in the host machine and the second port number.
11. The host machine according to any one of claims 8-10, wherein, The container orchestration tool is used to, in response to the startup of the first container, create a virtual network interface card (NIC) bound to the first container; allocate an Internet Protocol (IP) address and a port number to the virtual NIC according to an address configuration file, wherein the IP address of the virtual NIC is different from the IP address of the host machine, and the port number of the virtual NIC is different from the port number corresponding to the first container; the first container is used to send a second pending request, the second pending request including the IP address of the virtual NIC bound to the first container and the port number of the virtual NIC; receive a second response result sent by the second container; the second container is used to respond to the second pending request to generate the second response result; according to The Internet Protocol address and port number of the virtual network interface card are used to send the second response result. The second pending request and the second response result are transmitted using the Transmission Control Protocol (TCP).
12. A host machine, wherein, include: The memory and processor, and a first container and a second container running in an isolated environment constructed from the memory and the processor; The first container is used to send a pending request, wherein the pending request includes the Internet Protocol address and port number corresponding to the first container, the Internet Protocol address includes the Internet Protocol address of the host machine or the Internet Protocol address of the virtual network interface card bound to the first container, and the port number includes the port number of the host machine or the port number of the virtual network interface card bound to the first container, the Internet Protocol address and port number of the virtual network interface card being determined when the first container starts; the second container is used to respond to the pending request to generate the response result; The response result is sent according to the Internet Protocol address of the virtual network card and the virtual network card. The pending request and the response result are transmitted via RDMA protocol and / or Transmission Control Protocol TCP transmission through remote memory.
13. A host machine, wherein, include: Memory and processor, and containers running in an isolated environment constructed from said memory and processor; The memory is used to store computer programs; The processor is configured to execute the computer program to implement the inter-container communication method as described in any one of claims 1 to 7.
14. A non-transitory machine-readable storage medium, wherein, The non-transitory machine-readable storage medium stores executable code, which, when executed by a processor of a non-transitory machine, causes the processor to perform the inter-container communication method as described in any one of claims 1 to 7.
15. A computer program product, wherein, It includes a computer program or instructions that, when executed by a processor, cause the processor to perform the steps of the inter-container communication method according to any one of claims 1 to 7. 18
Citation Information
Patent Citations
Controlling method and apparatus for container accessing
CN106130990A
Communication method and device
CN111541738A
Data interaction method and device, electronic equipment and computer storage medium
CN113419810A
Container service access method and system, storage medium and electronic equipment
CN114500537A
High performance networking across docker containers
US20200394048A1