CN114265667A - Management method, system, equipment and storage medium for container port mapping - Google Patents

Management method, system, equipment and storage medium for container port mapping Download PDF

Info

Publication number
CN114265667A
CN114265667A CN202111583985.1A CN202111583985A CN114265667A CN 114265667 A CN114265667 A CN 114265667A CN 202111583985 A CN202111583985 A CN 202111583985A CN 114265667 A CN114265667 A CN 114265667A
Authority
CN
China
Prior art keywords
mapping
container
port
management
proxy
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.)
Pending
Application number
CN202111583985.1A
Other languages
Chinese (zh)
Inventor
李世晨
范渊
刘博�
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
DBAPPSecurity Co Ltd
Original Assignee
DBAPPSecurity Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by DBAPPSecurity Co Ltd filed Critical DBAPPSecurity Co Ltd
Priority to CN202111583985.1A priority Critical patent/CN114265667A/en
Publication of CN114265667A publication Critical patent/CN114265667A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The application discloses a management method of container port mapping, which is applied to a pre-established proxy container with network data transmission service and proxy mapping service, and comprises the following steps: receiving a mapping management command; and configuring gateway service according to the information carried in the mapping management command so as to perform mapping binding management between the port of the host machine and the port of the application container. By applying the scheme of the application, the management of the mapping of the container port can be conveniently and effectively realized, and the management is irrelevant to the state of the application container. The application also provides a management system, equipment and a storage medium for the container port mapping, and the management system, the equipment and the storage medium have corresponding technical effects.

Description

Management method, system, equipment and storage medium for container port mapping
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, a system, a device, and a storage medium for managing container port mapping.
Background
At present, the container deployment of the application can be performed through the container management platform, which greatly facilitates the deployment of the application, when the container is created by using the container mirror image, the online environment declares that the created container is mapped to the port of the host, and the mapping configuration from the container port to the port of the host can be modified by re-creating the container.
It is relatively easy to modify the mapping configuration of ports by means of rebuilding for stateless application containers, but not feasible for stateful application containers, since state or data recovery delays after rebuilding a container necessarily lead to service outages, which are catastrophic in a production environment.
Currently, it is more applicable to configure nat traffic forwarding rules through an Iptables tool built in the Linux system, so as to map a host port to a container port. However, each time the container is restarted, the network address is changed, and the nat traffic forwarding rule needs to be modified again, and meanwhile, a large number of Iptables policies cause network delay and configuration conflict in the forwarding process, that is, rule conflict is easy to occur, and the port mapping rule is invalid, so that the Iptables method can only be used as a temporary scheme and has no stability in a production environment.
In summary, how to conveniently and effectively implement container port mapping is a technical problem that needs to be solved urgently by those skilled in the art.
Disclosure of Invention
The invention aims to provide a management method, a system, equipment and a storage medium for container port mapping, so as to conveniently and effectively realize the container port mapping.
In order to solve the technical problems, the invention provides the following technical scheme:
a management method of container port mapping is applied to a pre-created proxy container with network data transmission service and proxy mapping service, and comprises the following steps:
receiving a mapping management command;
and configuring gateway service according to the information carried in the mapping management command so as to perform mapping binding management between the port of the host machine and the port of the application container.
Preferably, the gateway service is an nginx gateway service, and the receiving a mapping management command includes:
a mapping management command is received through the RESTAPI interface.
Preferably, the mapping management command is a command line selected from a dynamic mapping program created in advance and uploaded to the server.
Preferably, the container management platform built in the server is a docker container management platform.
Preferably, the proxy container is a proxy container installed by the dynamic mapping program.
Preferably, the performing mapping binding management between the host port and the application container port includes:
and adding, modifying or deleting the mapping binding between the host port and the application container port.
Preferably, the method further comprises the following steps:
and after receiving a server state query command, querying and feeding back a current port mapping relation list of the server.
A management system for container port mapping is applied to a pre-created proxy container with a network data transmission service and a proxy mapping service, and comprises the following steps:
a mapping management command receiving unit for receiving a mapping management command;
and the execution unit is used for configuring gateway services according to the information carried in the mapping management command so as to perform mapping binding management between the port of the host machine and the port of the application container.
A management device for container port mapping, comprising:
a memory for storing a computer program;
a processor for executing said computer program for implementing the steps of the method for managing a container port mapping as defined in any one of the preceding claims.
A computer-readable storage medium having stored thereon a computer program which, when being executed by a processor, carries out the steps of the method of managing container port mappings as set forth in any one of the preceding claims.
By applying the technical scheme provided by the embodiment of the invention, the proxy container is arranged and is provided with the network data transmission service, so that the data transmission between the host and the application container can be normally finished, meanwhile, the proxy container of the invention is also provided with the proxy mapping service, so that the proxy container can support the management of the container port mapping of the invention, specifically, after the proxy container receives the mapping management command, the gateway service can be configured according to the information carried in the mapping management command, and the gateway service can determine the mapping relation between the port of the host and the port of the application container, so that the mapping binding management between the port of the host and the port of the application container can be carried out by modifying the configured gateway service, and the condition of rule conflict in the traditional scheme can not occur. In summary, the scheme of the application can conveniently and effectively realize the management of the mapping of the container port, and is irrelevant to the state of the application container.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flowchart illustrating a method for managing container port mapping according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a management system for container port mapping according to the present invention.
Detailed Description
The core of the invention is to provide a management method of container port mapping, which can conveniently and effectively realize the management of the container port mapping and is irrelevant to the state of an application container.
In order that those skilled in the art will better understand the disclosure, the invention will be described in further detail with reference to the accompanying drawings and specific embodiments. It is to be understood that the described embodiments are merely exemplary of the invention, and not restrictive of the full scope of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, fig. 1 is a flowchart illustrating a method for managing a container port mapping according to the present invention, where the method for managing a container port mapping is applied to a pre-created proxy container having a network data transmission service and a proxy mapping service, and includes the following steps:
step S101: a mapping management command is received.
In the scheme of the application, the proxy container is provided with the network data transmission service, so that data transmission between the host and the application container can be realized, and the proxy mapping service is also provided, so that mapping management can be realized.
The agent container may be deployed in a server, and in practical applications, a server cluster is generally formed by a plurality of server nodes, and then each server may configure 1 agent container to implement the solution of the present application.
Because containerized deployment of applications is required, a container application platform is required to be built in a server, most of applications and dependency packages can be packaged into a portable mirror image considering that docker is an open-source application container engine, and then the application and dependency packages are released to any popular Linux server, so that the deployment of undifferentiated testing and release basic environments can be realized, and meanwhile, virtualization can also be realized. Therefore, in the scheme of the application, the container management platform built in the server can be a docker container management platform. In addition, when a network management environment is deployed, a sweep environment is typically deployed.
The staff can input the mapping management command, the mapping management command can carry the specific operation content of the mapping management required at this time, and the proxy container receives the mapping management command.
Step S102: and configuring gateway service according to the information carried in the mapping management command so as to perform mapping binding management between the port of the host machine and the port of the application container.
After the proxy container receives the mapping management command, the gateway service can be configured according to the information carried in the mapping management command. The gateway service can determine the mapping relation between the port of the host machine and the port of the application container, so that the mapping binding management between the port of the host machine and the port of the application container can be carried out by modifying and configuring the gateway service, and the gateway service is irrelevant to the state of the application container and does not have the condition of rule conflict.
In a specific embodiment, the gateway service may be specifically a nginx gateway service. When nginx is adopted as gateway service, the installation is simple, the configuration file is concise, and the starting is easy. Correspondingly, step S101 may specifically include: a mapping management command is received through the RESTAPI interface.
REST (representationstate Transfer, REST) describes an architecture style network system, and sets a set of architecture constraints and principles, and an application or design that satisfies these constraints and principles is RESTful. RESTAPI (Application Programming Interface), a RESTful API, indicates an Interface based on REST rules.
In this embodiment, the proxy container may receive the mapping management command through the RESTAPI interface, and further may configure the nginx gateway service in the RESTAPI manner, that is, the proxy container is a container that manages the configuration of the nginx gateway service in the RESTAPI encapsulation manner, so that mapping binding management between the host port and the application container port may be performed.
When performing mapping binding management between a host port and an application container port, the mapping binding management may generally specifically include: the addition, modification or deletion of mapping binding between the host port and the application container port is also a common operation in the management of container port mapping.
In one embodiment of the present invention, the mapping management command is a command line selected from a dynamic mapping program created in advance and uploaded to the server.
In the implementation mode, in order to conveniently input the mapping management command, a dynamic mapping program, which may be called a port program, is created in advance and uploaded to the server, so that a corresponding command line can be directly selected from the dynamic mapping program in the following step to serve as the currently required mapping management command, which is simple and convenient.
For example, in one embodiment of the present invention, a command line of a previously created maprt program may be sent to the RESTAPI interface and identified, and the following is a description of the maprt program in one embodiment:
NAME:maport
SYNOPSIS:maport[OPTIONS][VALUE]
DESCRIPTION:
-s/status
checking the service state;
-l/list
obtaining port mapping list, obtaining relative port mapping list by-n appointed application container name
-n
Specifying mapping container names
-d/delete
Deleting mappings requiring specifying application container names
The format is as follows: maport-d host _ port [ [ container _ port ] ]n [ container _ port ]
Example (c): maport-d 3306:3306-n mysql
-p/mapping
Adding or changing port mappings requires specifying application container names
The format is as follows: map port-p [ host _ port ], [ container _ port ] -n [ container _ name ]
Example (c): maport-p 3306:3306-n mysql
install
Creating proxy containers
uninstall
And unloading the proxy container.
It can be seen that, in this embodiment, when the mapping binding between the host port and the application container port needs to be increased or modified, the mapping management command may be implemented by a map port-p [ host _ port ], [ container _ port ] -n [ container _ name ], where-n [ container _ name ] in the mapping management command is used to specify the application container that needs to be operated at this time, and p [ host _ port ], [ container _ port ] is used to specify the host port and the port of the application container. And the mapping management command of map port-d host port, container port, n container name can delete the mapping binding between the host port and the application container port.
In this embodiment, the proxy container may be created by the command line of the maport program, or the proxy container may be uninstalled. That is to say, the agent container may be an agent container installed through a dynamic mapping program, so that when a worker executes the scheme of the application, the worker only needs to create the dynamic mapping program in advance and upload the dynamic mapping program to the server, and then various required operations, including creation and uninstallation of the agent container, and addition, deletion and modification of mapping binding between the host port and the application container port, may be implemented based on the dynamic mapping program.
In one embodiment of the present invention, the method further comprises: and after receiving a server state query command, querying and feeding back a current port mapping relation list of the server.
In this embodiment, the addition, deletion, and modification of the mapping binding between the host port and the application container port are performed by the staff conveniently. The current port mapping relation list of the server can be displayed, so that the work of workers is assisted. In the foregoing embodiment, the command line-l/list of the maport program can be used to implement, that is, the command line-l/list can be used as a server status query command.
By applying the technical scheme provided by the embodiment of the invention, the proxy container is arranged and is provided with the network data transmission service, so that the data transmission between the host and the application container can be normally finished, meanwhile, the proxy container of the invention is also provided with the proxy mapping service, so that the proxy container can support the management of the container port mapping of the invention, specifically, after the proxy container receives the mapping management command, the gateway service can be configured according to the information carried in the mapping management command, and the gateway service can determine the mapping relation between the port of the host and the port of the application container, so that the mapping binding management between the port of the host and the port of the application container can be carried out by modifying the configured gateway service, and the condition of rule conflict in the traditional scheme can not occur. In summary, the scheme of the application can conveniently and effectively realize the management of the mapping of the container port, and is irrelevant to the state of the application container.
Corresponding to the above method embodiments, embodiments of the present invention further provide a management system for container port mapping, which can be referred to in correspondence with the above.
Referring to fig. 2, a schematic structural diagram of a management system for container port mapping in the present invention is applied to a pre-created proxy container having a network data transmission service and a proxy mapping service, and includes:
a mapping management command receiving unit 201 for receiving a mapping management command;
the execution unit 202 is configured to configure a gateway service according to the information carried in the mapping management command, so as to perform mapping binding management between the host port and the application container port.
In a specific embodiment of the present invention, the gateway service is an nginx gateway service, and the mapping management command receiving unit 201 is specifically configured to:
a mapping management command is received through the RESTAPI interface.
In one embodiment of the present invention, the mapping management command is a command line selected from a dynamic mapping program created in advance and uploaded to the server.
In a specific embodiment of the present invention, the container management platform built in the server is a docker container management platform.
In one embodiment of the invention, the proxy container is a proxy container installed by a dynamic mapping program.
In a specific embodiment of the present invention, the executing unit 202 performs mapping binding management between a host port and an application container port specifically includes:
and adding, modifying or deleting the mapping binding between the host port and the application container port.
In an embodiment of the present invention, the execution unit 202 is further configured to:
and after receiving a server state query command, querying and feeding back a current port mapping relation list of the server.
Corresponding to the above method embodiments, the embodiments of the present invention further provide a management apparatus for container port mapping and a computer-readable storage medium, which may be referred to in correspondence with the above. The computer readable storage medium has stored thereon a computer program which, when being executed by a processor, carries out the steps of the method for managing a container port mapping according to any of the above embodiments. A computer-readable storage medium as referred to herein may include Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The management device of the container port mapping may include:
a memory for storing a computer program;
a processor for executing a computer program for implementing the steps of the method for managing container port mapping as in any of the above embodiments.
It is further noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The principle and the implementation of the present invention are explained in the present application by using specific examples, and the above description of the embodiments is only used to help understanding the technical solution and the core idea of the present invention. It should be noted that, for those skilled in the art, it is possible to make various improvements and modifications to the present invention without departing from the principle of the present invention, and those improvements and modifications also fall within the scope of the claims of the present invention.

Claims (10)

1. A management method for container port mapping is applied to a pre-created proxy container with a network data transmission service and a proxy mapping service, and comprises the following steps:
receiving a mapping management command;
and configuring gateway service according to the information carried in the mapping management command so as to perform mapping binding management between the port of the host machine and the port of the application container.
2. The method for managing container port mapping according to claim 1, wherein the gateway service is a nginx gateway service, and the receiving a mapping management command includes:
a mapping management command is received through the RESTAPI interface.
3. The method for managing container port mapping according to claim 1, wherein the mapping management command is a command line selected from a dynamic mapping program created in advance and uploaded to a server.
4. The management method of the container port mapping according to claim 3, wherein the container management platform built in the server is a docker container management platform.
5. The method for managing container port mapping according to claim 3, wherein the proxy container is a proxy container installed by the dynamic mapping program.
6. The method for managing container port mapping according to claim 1, wherein the performing mapping binding management between the host port and the application container port comprises:
and adding, modifying or deleting the mapping binding between the host port and the application container port.
7. The method for managing container port mapping according to any of claims 1 to 6, further comprising:
and after receiving a server state query command, querying and feeding back a current port mapping relation list of the server.
8. A management system for container port mapping is applied to a pre-created proxy container with a network data transmission service and a proxy mapping service, and comprises the following steps:
a mapping management command receiving unit for receiving a mapping management command;
and the execution unit is used for configuring gateway services according to the information carried in the mapping management command so as to perform mapping binding management between the port of the host machine and the port of the application container.
9. A management device for container port mapping, comprising:
a memory for storing a computer program;
a processor for executing said computer program for implementing the steps of the method for managing a container port mapping according to any of claims 1 to 7.
10. A computer-readable storage medium, characterized in that a computer program is stored thereon, which computer program, when being executed by a processor, carries out the steps of the method for managing container port mappings according to one of claims 1 to 7.
CN202111583985.1A 2021-12-22 2021-12-22 Management method, system, equipment and storage medium for container port mapping Pending CN114265667A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111583985.1A CN114265667A (en) 2021-12-22 2021-12-22 Management method, system, equipment and storage medium for container port mapping

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111583985.1A CN114265667A (en) 2021-12-22 2021-12-22 Management method, system, equipment and storage medium for container port mapping

Publications (1)

Publication Number Publication Date
CN114265667A true CN114265667A (en) 2022-04-01

Family

ID=80829668

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111583985.1A Pending CN114265667A (en) 2021-12-22 2021-12-22 Management method, system, equipment and storage medium for container port mapping

Country Status (1)

Country Link
CN (1) CN114265667A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115002069A (en) * 2022-06-24 2022-09-02 中国电信股份有限公司 Port mapping method and device, electronic equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115002069A (en) * 2022-06-24 2022-09-02 中国电信股份有限公司 Port mapping method and device, electronic equipment and storage medium
CN115002069B (en) * 2022-06-24 2023-10-31 中国电信股份有限公司 Port mapping method, device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN107580083B (en) Method and system for allocating IP addresses of containers
WO2016121802A1 (en) Virtualization management/orchestration apparatus, virtualization management/orchestration method, and program
CN107357660A (en) The distribution method and device of a kind of virtual resource
CN112035216B (en) Communication method for Kubernetes cluster network and OpenStack network
CN107741852B (en) Service deployment method based on cluster software
EP3432132A1 (en) Data storage method and device
CN111787126A (en) Container creation method, server, and storage medium
CN113849266A (en) Service deployment method and device for multiple Kubernetes clusters
CN113810230A (en) Method, device and system for carrying out network configuration on containers in container cluster
CN108804100B (en) Method and device for creating interface element, storage medium and mobile terminal
CN111831567B (en) Application test environment configuration method, device, system and medium
CN110990356B (en) Real-time automatic capacity expansion method and system for logical mirror image
CN114265667A (en) Management method, system, equipment and storage medium for container port mapping
CN115421740A (en) Deployment method and device of cloud native application
CN114356504A (en) Data migration method and device in cluster, electronic equipment and storage medium
US11681585B2 (en) Data migration for a shared database
US20230359450A1 (en) Cloud application engine deployment method for shielding web framework from users and apparatus, device and storage medium thereof
CN114827177B (en) Deployment method and device of distributed file system and electronic equipment
CN108897581B (en) Service deployment method and device and electronic equipment
CN108334374A (en) The method and apparatus of component dynamic load and execution
CN114884955B (en) Transparent proxy deployment system and method
CN112910956A (en) Resource creating method and device and electronic equipment
CN112463305A (en) Management method, system and related device of cloud virtualization GPU
US11924031B2 (en) Highly scalable container network interface operation to reduce startup overhead of functions
US20240195685A1 (en) Highly scalable container network interface operation to reduce startup overhead of functions

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination