Container access method and device, equipment, storage medium and product
By using the command line interface in the application to obtain container connection information and establish network socket connections, the problem of cumbersome web access containers and browser dependence is solved, and an efficient and convenient container access experience is achieved.
Patent Information
- Application Number
- CN202510503810.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-21
- Publication Date
- 2025-08-01
AI Technical Summary
In the prior art, accessing containers through web pages requires multiple page jumps and relying on browser performance, resulting in poor user experience and does not conform to the operating habits of developers.
Receive commands through the command line interface in the preset application, obtain the connection information of the container, and establish a network socket connection to achieve direct interaction with the container.
It improves the convenience of container access, reduces browser dependence and lag, provides operation methods that meet developers' habits, and improves user experience.
Smart Images

Figure CN120407969A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the field of computer technologies, and in particular, to a container access method, apparatus, device, storage medium, and product. Background Art
[0002] A container is a lightweight virtualization technology that can be used to run application programs and their dependencies. Containers use a sandbox mechanism. Each container can contain all the code, libraries, system tools, configuration files, etc. required to run an application, without relying on the environment of the host operating system, achieving decoupling of the application program from the operating system. Developers can run code or perform other related operations within the container, such as editing files and viewing logs.
[0003] Currently, developers access containers through a web page, and need to go through multiple page jumps and operations to find and access the required container. Moreover, this access method depends on the performance of the browser, and there will be lags when the browser load is heavy. In addition, the web-based operation method is quite different from the operation methods that developers are used to, resulting in a poor user experience. Summary of the Invention
[0004] Embodiments of the present disclosure provide a container access method, apparatus, device, storage medium, and product, which can optimize the existing container access solution.
[0005] In a first aspect, embodiments of the present disclosure provide a container access method, including:
[0006] Receiving a first command based on a command-line interface in a preset application program, and obtaining connection information of a target container from a container management system based on the first command;
[0007] Establishing a network socket connection with the target container based on the connection information;
[0008] Receiving a second command based on the command-line interface, and interacting with the target container through the network socket connection based on the second command.
[0009] In a second aspect, embodiments of the present disclosure further provide a container access apparatus, including:
[0010] A connection information acquisition module, configured to receive a first command based on a command-line interface in a preset application program, and obtain connection information of a target container from a container management system based on the first command;
[0011] A connection establishment module, configured to establish a network socket connection with the target container based on the connection information;
[0012] A container access module, configured to receive a second command based on the command line interface and interact with the target container through the network socket connection based on the second command.
[0013] In a third aspect, an embodiment of the present disclosure further provides an electronic device, including:
[0014] One or more processors;
[0015] A storage device for storing one or more programs,
[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement the container access method provided by the embodiments of the present disclosure.
[0017] In a fourth aspect, an embodiment of the present disclosure further provides a storage medium containing computer-executable instructions, which are used to execute the container access method provided by the embodiments of the present disclosure when executed by a computer processor.
[0018] In a fifth aspect, an embodiment of the present disclosure further provides a computer program product, including a computer program, which implements the container access method provided by the embodiments of the present disclosure when executed by a processor.
[0019] The container access solution provided by the embodiments of the present disclosure receives a first command based on the command line interface in a preset application program, obtains the connection information of the target container from the container management system based on the first command, establishes a network socket connection with the target container based on the connection information, receives a second command based on the command line interface, and interacts with the target container through the network socket connection based on the second command. By adopting the above technical solution, commands can be received based on the command line interface in the preset application program, and containers can be selected and interacted with based on the commands. Compared with the traditional method of accessing containers based on web pages, the convenience of container access can be improved, and there is no need to rely on browser performance, reducing the occurrence of lag. Developers can use their accustomed command line operation methods to access containers, effectively enhancing the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In combination with the drawings and referring to the following specific embodiments, the above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic, and the original components and elements are not necessarily drawn to scale.
[0021] Figure 1 It is a schematic flowchart of a container access method provided by an embodiment of the present disclosure;
[0022] Figure 2 Flow chart of another container access method provided by an embodiment of the present disclosure;
[0023] Figure 3 Interaction diagram of a container access process provided by an embodiment of the present disclosure;
[0024] Figure 4 Flow chart of another container access method provided by an embodiment of the present disclosure;
[0025] Figure 5 Structural diagram of a container access device provided by an embodiment of the present disclosure;
[0026] Figure 6 Structural diagram of an electronic device provided by an embodiment of the present disclosure. Detailed implementation manners
[0027] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although some embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. On the contrary, these embodiments are provided to more thoroughly and completely understand the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not used to limit the protection scope of the present disclosure.
[0028] It should be understood that the steps recited in the method embodiments of the present disclosure can be executed in a different order and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this regard.
[0029] The term "including" and its variants used herein are open-ended, that is, "including but not limited to". The term "based on" is "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0030] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependence.
[0031] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive. Those skilled in the art should understand that unless otherwise clearly stated in the context, it should be understood as "one or more".
[0032] Figure 1 The following is a schematic flowchart of a container access method provided by an embodiment of the present disclosure. The embodiment of the present disclosure is applicable to the situation of container access. This method can be executed by a container access device, and the device can be implemented in the form of software and / or hardware. Optionally, it can be implemented by an electronic device, which can be a mobile terminal such as a tablet computer and a personal digital assistant, or can also be a device such as a personal computer (PC) or a server.
[0033] As Figure 1 shown, the method includes:
[0034] Step 101: Receive a first command based on the command line interface in a preset application, and obtain connection information of a target container from a container management system based on the first command.
[0035] Exemplarily, the preset application is installed in the electronic device, and a command line tool can be integrated in the preset application. After running the preset application in the electronic device, a command line interface corresponding to the command line tool can be displayed. The container in the embodiment of the present disclosure is a container in a container management system, and the container management system can be implemented based on any container management platform, which is not specifically limited. It can unify the interface adaptation layer, abstract the interface differences of different container management platforms, implement a unified access protocol, and support the extensible access of the container management platform.
[0036] In the related art, a user (usually a developer) needs to access a container through a web page. When accessing a container through a web page, generally, the display of a service set needs to be triggered first, a service is selected in the service set, the page jumps to the page of the selected service after the service is selected, a cluster list is displayed on the page of the selected service, a cluster is selected in the cluster list, the page jumps to the page of the selected cluster after the cluster is selected, a container list (or instance list, where a container and an instance generally have a one-to-one correspondence) is displayed on the page of the selected cluster, and finally a container is selected in the container list to access the selected container. In the above process, multiple page jumps and selection operations are involved, which are cumbersome and time-consuming. Moreover, this access method depends on the performance of the browser, and there will be lags when the browser load is heavy. The operation method based on the web page also has a large difference from the operation method with which developers are accustomed, resulting in poor user experience.
[0037] In the embodiment of the present disclosure, a user can input a command related to requesting access to a target container based on the command line interface, denoted as the first command. The first command can be a command directly requesting access to the target container or a command indirectly requesting access to the target container. For example, it can be a command to access a superior object (such as a cluster or a service) of the target container. The first command can include a container identifier of the target container or an object identifier of a superior object of the target container, etc.
[0038] Exemplarily, the connection information of the target container may include relevant information for establishing a WebSocket connection with the target container, such as the WebSocket service port, path, and relevant parameters, etc. Optionally, the interaction between the preset application and the container may be implemented based on a preset interaction protocol, and the preset interaction protocol may be implemented based on WebSocket, such as a Web shell (Webshell). First, the relevant information of the preset interaction protocol may be obtained, and the connection information of the target container may be obtained from the relevant information of the preset interaction protocol.
[0039] Step 102: Establish a WebSocket connection with the target container based on the connection information.
[0040] Exemplarily, after obtaining the connection information of the target container, a WebSocket connection between the preset application and the target container may be established based on the connection information. WebSocket is a network communication protocol that allows the establishment of a persistent and two-way communication channel between the client and the server. Different from the traditional HyperText Transfer Protocol (HTTP), WebSocket supports full-duplex communication, that is, the client and the server can send and receive data simultaneously, making the data transmission between the preset application and the target container more time-sensitive and conducive to improving the interaction efficiency.
[0041] Step 103: Receive a second command based on the command line interface, and interact with the target container through the WebSocket connection based on the second command.
[0042] In the embodiments of the present disclosure, after establishing the WebSocket connection, the commands input by the user based on the command line interface may be collectively referred to as the second commands, and the quantity and specific types of the second commands are not limited. The user can conveniently interact with the target container by inputting the second commands in the command line interface. For example, running code, editing files, and viewing logs in the container, etc. Compared with the container access solution based on the web page, the implementation based on the preset application in the embodiments of the present disclosure can support many shortcut operations in the command line tool, including some shortcut key operations often used by developers. For example, after inputting the string "aaa bbb ccc ddd", if it is necessary to delete "aaa", in the browser, the cursor needs to be moved forward one by one to the third character "a" and then delete 3 "a" one by one. In the command line tool, it can be quickly moved to before the first "a" by inputting the shortcut key, or a word can be deleted at once by inputting the shortcut key, that is, deleting 3 "a" at once, which can effectively improve the input efficiency and thus improve the interaction efficiency with the target container.
[0043] The container access method provided by an embodiment of the present disclosure receives a first command based on a command line interface in a preset application, obtains connection information of a target container from a container management system based on the first command, establishes a network socket connection with the target container based on the connection information, receives a second command based on the command line interface, and interacts with the target container through the network socket connection based on the second command. By adopting the above technical solution, commands can be received based on the command line interface in the preset application, and containers can be selected and interacted with based on the commands. Compared with the traditional method of accessing containers based on a web page, the convenience of container access can be improved, and there is no need to rely on browser performance, reducing the occurrence of lag. Developers can use their accustomed command line operation methods to access containers, effectively enhancing the user experience.
[0044] In some embodiments, the first command includes a container identifier of the target container. Thus, the connection information of the target container can be quickly obtained by inputting a single command line. For example, in scenarios such as container alarms, the container identifier of the container with an anomaly (assumed as the target container) is usually included in the alarm information. The user can quickly enter the alarmed container, i.e., the target container, by inputting the first command specifying the container identifier in the command line interface through methods such as copy-pasting or manual input.
[0045] In some embodiments, for scenarios where the user does not clearly know the container identifier of the target container, the first command may include an object identifier of a superior object of the target container, or may include information related to searching for a list of all services in the container management system.
[0046] Optionally, the step of receiving a first command based on a command line interface in a preset application and obtaining connection information of a target container from a container management system based on the first command includes: receiving a first command based on a command line interface in a preset application, and obtaining a target object set from the container management system based on the first command, where the target object set includes at least one of a container set in a target cluster to which the target container belongs, a cluster set in a target service to which the target cluster belongs, and a service set to which the target service belongs; displaying the target object set in the command line interface; receiving an interaction operation on the target object set based on the command line interface, and sending a connection information acquisition request for the target container to the container management system based on the interaction operation; and receiving the connection information of the target container sent by the container management system. Thus, by combining the input of commands and interaction operations, the target container can be quickly selected and the connection information can be obtained.
[0047] Exemplarily, the target container is included in the target cluster. The first command may include the cluster identifier of the target cluster, that is, the first command may be a command for directly accessing the target cluster. Based on the first command, a set of all containers included in the target cluster, that is, the container set (which can be in the form of a list, that is, a container list), is obtained from the container management system. The target cluster is included in the target service. The first command may include the service identifier of the target service, that is, the first command may be a command for directly accessing the target service. Based on the first command, a set of all clusters included in the target service, that is, the cluster set (which can be a cluster list), is obtained from the container management system. The target service is included in the service set. The first command may include information for accessing all services, that is, the first command may be a command for accessing all services. Based on the first command, a set of all services managed by the container management system, that is, the service set (which can be a service list), is obtained from the container management system. For some special cases, there may be only one service managed in the container management system, or there may be only one cluster in a certain service, or there may be only one instance in a certain cluster. The existing highest-level list can be directly returned. For example, if there may be only one service managed in the container management system and the first command includes information for accessing all services, the cluster set of the service can be directly returned.
[0048] Exemplarily, after the target object set is obtained from the container management system, the target object set is displayed in the command-line interface. The user can view the target object set and receive interaction operations for the target object set based on the command-line interface. The number of times of the interaction operation can be one or more, and there is no specific limitation. By inputting the interaction operation, the container to be selected is determined as the target container, so as to send a connection information acquisition request for the target container to the container management system. Exemplarily, assuming that the target object set obtained from the container management system based on the first command is the service set, the target service can be selected from the service set based on the interaction operation, and a request for obtaining the cluster set of the target service is sent to the container management system. The cluster set in the target service is received and displayed. The interaction operation can be input again. Based on the interaction operation, the target cluster is selected from the cluster set, and a request for obtaining the container set of the target cluster is sent to the container management system. The container set in the target service is received and displayed. The interaction operation can be input again. Based on the interaction operation, the target container is selected from the container set, and then a connection information acquisition request for the target container is sent to the container management system, and the connection information of the target container sent by the container management system is received.
[0049] In an embodiment of the present disclosure, after establishing a Websocket connection with a target container, a preset application can send corresponding standard input data to the target container based on a second command received from a command-line interface via the Websocket connection, receive output data returned by the target container, and display it to the standard output at the command-line interface.
[0050] In the related art, there are already mature processing solutions for standard input and output data in web browsers, while in the embodiments of the present disclosure, it needs to be implemented in a preset application. The specific implementation method is not limited. The following embodiments will illustrate an optional implementation method.
[0051] Figure 2 FIG. is a schematic flowchart of another container access method provided by an embodiment of the present disclosure. The embodiments of the present disclosure are optimized based on the above various optional solutions. Specifically, the method includes the following steps:
[0052] Step 201, create an input / output buffer corresponding to the command-line interface, and connect the standard input stream of the system to the input / output buffer, where the data in the input / output buffer is used to be displayed at the command-line interface.
[0053] Among them, standard input data (Standard Input Data, stdin) is the input data received from the outside during the operation of the program, such as the data input through the keyboard. These data are usually passed to the program through the standard input stream (Standard InputStream) of the system. The standard input stream is a special input stream used to receive user input or data transferred from other sources (such as files or pipes). In the embodiments of the present disclosure, a preset application can create a custom input / output buffer for storing and managing input / output data, and by redirecting the standard input stream of the system to the custom input / output buffer, the connection of the standard input stream of the system to the input / output buffer is realized.
[0054] Step 202, receive a first command based on the command-line interface in the preset application, and obtain connection information of the target container from the container management system based on the first command.
[0055] Optionally, before this step, access credentials can be obtained from the authentication component in the container management system to obtain authorization to access the container management system. Based on the access credentials, a preset interface in the container management system can be accessed, such as an Open Application Programming Interface (Open API). The specific implementation of the authentication component is not limited. For example, it can be an authentication module based on terminal Single Sign-On (SSO), which can be logged in through Open Authorization (OAuth). For example, it can support login methods such as QR code scanning login based on OAuth, and the access credentials can be saved in a local file in a preset application to avoid repeated logins.
[0056] Figure 3 It is an interaction schematic diagram of a container access process provided by an embodiment of the present disclosure. As Figure 3 shown, first, enter the login process. The preset application obtains a unique code from the authentication component of the container management system, logs in through the open authorization method, and polls through a loop logic to check whether the login is successful. If the login fails, a device open authorization QR code is obtained again. If the code is scanned and the login is successful, it is shown that the login is successful, and the open authorization token (access credentials) is saved to a file.
[0057] Exemplarily, the user enters a first command based on the command line interface. The data of the first command exists in the standard input stream. The first command can be obtained from the standard data stream and stored in the input / output buffer to implement the display of the first command in the command line interface, and the connection information of the target container is requested from the container management system according to the first command. Exemplarily, after receiving the first command, the connection information of the target container can be obtained by accessing the preset interface based on the access credentials.
[0058] As Figure 3 shown, after the login process ends, enter the container acquisition process. The service list can be obtained by entering the first command. After the service list is displayed in the command line interface, the service is selected through an interactive operation to obtain the cluster list of the selected service. After the cluster list is displayed in the command line interface, the cluster is selected through an interactive operation to obtain the instance list of the selected cluster. After the instance list is displayed in the command line interface, the instance is selected through an interactive operation, that is, the target container is selected, and the Websocket connection information of the instance can be obtained.
[0059] Step 203: Establish a network socket connection with the target container based on the connection information.
[0060] As Figure 3As shown, after the container acquisition process ends, it enters the data transmission process based on the Websocket connection, and a Websocket connection is established with the target container (the target container is represented by the container management system in the figure) based on the Websocket connection information.
[0061] Step 204: Obtain the second command input by the user based on the command line interface from the standard input stream of the system, and store the second command in the input / output buffer.
[0062] Exemplarily, the user inputs the second command based on the command line interface, and the data of the second command exists in the standard input stream. The second command can be obtained from the standard data stream and stored in the input / output buffer to implement the display of the second command in the command line interface.
[0063] Step 205: In response to a preset sending operation, send the second command stored in the input / output buffer to the target container through the network socket connection.
[0064] Exemplarily, the preset sending operation can be, for example, a carriage return operation. After receiving the carriage return operation, the second command stored in the input / output buffer is sent to the target container through the Websocket connection.
[0065] Exemplarily, in the case where the second command does not include a preset character (such as special characters like control characters or characters corresponding to preset keys, and preset keys such as special keys like ctrl), the second command can be directly sent to the target container. The second command can also include a preset character. Optionally, in response to the second command including a preset character, the preset character is encoded, and the encoding result is sent to the target container through the Websocket connection. For example, the preset character includes ctrl+c, which is a combination key used in the command line tool to interrupt or terminate the currently running process. When it is detected that the second command includes ctrl+c, the currently executing command needs to be interrupted, and the preset character is encoded into a symbol recognizable by the target container as the encoding result and sent to the target container.
[0066] Step 206: Update the display content in the command line interface according to the return data of the target container.
[0067] As Figure 3 shown, send standard input data to the target container, receive the output data returned by the target container, and display it on the standard output.
[0068] Optionally, this step may include: in response to the return data of the target container including data to be displayed, storing the data to be displayed in the input / output buffer and displaying the data to be displayed in the command-line interface; and / or, in response to the return data of the target container including a control instruction, updating the display content in the command-line interface based on the control instruction.
[0069] Exemplarily, after receiving the second command, the target container performs corresponding processing according to the second command and returns corresponding data to the preset application. The returned data is denoted as return data. The return data may include data to be displayed and may include control instructions. For the case where only data to be displayed is included, such as when the second command is a command to request viewing the log, the return data of the target container is the log content, which is the data to be displayed. Then, the data to be displayed is stored in the input / output buffer and the log content is displayed in the command-line interface. For the case where only a control command is included, such as when the second command in the above example includes ctrl+c, the target container performs corresponding operations after receiving the corresponding encoding result, such as interrupting the currently executing command. Then, the return data includes a control instruction for interruption. After receiving this control instruction, the preset application pauses the display of the undisplayed data in the input / output buffer in the command-line interface. In the command-line interface, it can be manifested as interrupting the data display of the current line and entering the next line. Also, for example, when the second command includes the preset character clear, after receiving the corresponding encoding result, the return data of the target container includes a control instruction for clearing the screen. After receiving this control instruction, the preset application clears the display content in the command-line interface. For the case where the return data includes both data to be displayed and a control instruction, for example, when the second command includes l, that is, the list command, after the target container receives the list command, it returns the file list in the current directory. The file list is the data to be displayed. In addition, the return data may further include a display attribute control instruction corresponding to the data to be displayed, such as a control instruction for controlling the display color. For example, the folder is displayed in blue, the executable file is displayed in green, and the file is displayed in white, etc. The data to be displayed is rendered and displayed in the command-line interface based on the display attribute control instruction, thereby updating the display content in the command-line interface.
[0070] As Figure 3 shown, after detecting the close instruction, such as detecting ctrl+d, the connection is closed and the access to the target container ends.
[0071] The container access method provided by the embodiment of the present invention presets that an application creates an input-output buffer corresponding to a command-line interface, connects the standard input stream of the system to the input-output buffer, receives a first command based on the command-line interface in the preset application, obtains connection information of a target container from a container management system based on the first command, establishes a network socket connection with the target container based on the connection information, simplifies multi-step operations of a web interface into a single command, improves container access efficiency, obtains a second command input by a user based on the command-line interface from the standard input stream of the system, stores the second command in the input-output buffer, and in response to a preset sending operation, sends the second command stored in the input-output buffer to the target container through the network socket connection, and updates the display content in the command-line interface according to the return data of the target container, so as to realize sending standard input data to the target container and displaying the return data of the target container in a standard output manner, provide a native terminal experience for the user, avoid performance limitations of the web interface, and improve the user experience.
[0072] In some embodiments, receiving a second command based on the command-line interface and interacting with the target container through the network socket connection based on the second command includes: receiving a second command based on the command-line interface; in response to the second command including a preset control character, performing an interaction operation corresponding to the preset control character with the target container through the network socket connection based on a preset control protocol corresponding to the preset control character. Thereby, some control protocols or tools that cannot be supported in some browsers can be supported in the application, enriching the functions of the application and further improving the convenience of container access.
[0073] In the related art, in a web-based container access solution, there are many control protocols that cannot be supported. If support is required, the browser needs to be greatly modified, with high modification costs and difficult implementation.
[0074] In the embodiment of the present disclosure, a container solution implemented based on an application can increase support for some control protocols, denoted as preset control protocols. The specific types of the preset control protocols are not limited. For example, they may include a file transfer control protocol, a container management control protocol, a data block transfer control protocol, or a character set conversion protocol, etc. The specific protocol types are not limited.
[0075] Figure 4 The flowchart of another container access method provided by the embodiment of the present disclosure optimizes the above embodiments based on each optional solution. The preset control protocol includes a file transfer control protocol, and the preset control character includes a file upload control character and / or a file download control character. Specifically, the method includes the following steps:
[0076] Step 401: Receive a first command based on the command line interface in the preset application, and obtain the connection information of the target container from the container management system based on the first command.
[0077] Step 402: Establish a network socket connection with the target container based on the connection information.
[0078] Step 403: Receive a second command based on the command line interface.
[0079] Step 404: In response to the second command including a file upload control character or a file download control character, display a file operation window above the command line interface.
[0080] Exemplarily, the file transfer control protocol may include the szrz protocol, etc., which is an open-source protocol for file transfer through special control characters. Among them, the file download control character may be sz. After identifying that the second command includes the file download control character, a file operation window can be displayed above the command line interface. The file directory can be displayed in the file operation window.
[0081] Step 405: In response to the file selection operation input based on the file operation window, perform a corresponding file upload operation or file download operation with the target container through the network socket connection based on the file transfer control protocol.
[0082] Exemplarily, the user can input a file selection operation for the file to be downloaded (denoted as the target file) based on the file operation window. After confirming the download, the target file can be downloaded from the target container through the Websocket connection based on the file transfer control protocol and saved to the preset file directory on the local side. The preset file directory can be pre-configured, such as the downloads directory.
[0083] The container access method provided by the embodiments of the present invention receives a first command based on the command line interface in the preset application, obtains the connection information of the target container from the container management system based on the first command, establishes a network socket connection with the target container based on the connection information, receives a second command based on the command line interface. When the second command contains a file upload control character or a file download control character, a file operation window can be displayed, and then file upload or file download operations with the target container can be performed, supporting some control protocols or tools that cannot be supported in some browsers in the application, enriching the functions of the application, and further improving the convenience of container access.
[0084] Figure 5 The following is a schematic structural diagram of a container access device provided by an embodiment of the present disclosure, as Figure 5 shown, the device includes:
[0085] A connection information acquisition module 501, configured to receive a first command based on a command line interface in a preset application program, and acquire connection information of a target container from a container management system based on the first command;
[0086] A connection establishment module 502, configured to establish a network socket connection with the target container based on the connection information;
[0087] A container access module 503, configured to receive a second command based on the command line interface, and interact with the target container through the network socket connection based on the second command.
[0088] The container access device provided by the embodiments of the present disclosure receives a first command based on a command line interface in a preset application program, acquires connection information of a target container from a container management system based on the first command, establishes a network socket connection with the target container based on the connection information, receives a second command based on the command line interface, and interacts with the target container through the network socket connection based on the second command. By adopting the above technical solutions, commands can be received based on the command line interface in the preset application program, and containers can be selected and interacted based on the commands. Compared with the traditional method of accessing containers based on web pages, the convenience of container access can be improved, and there is no need to rely on browser performance, reducing the occurrence of lag. Developers can use their accustomed command line operation methods to access containers, effectively enhancing the user experience.
[0089] Optionally, the connection information acquisition module includes:
[0090] A set acquisition unit, configured to receive a first command based on a command line interface in a preset application program, and acquire a target object set from a container management system based on the first command, where the target object set includes at least one of a container set in a target cluster to which the target container belongs, a cluster set in a target service to which the target cluster belongs, and a service set in a service set to which the target service belongs;
[0091] A set display unit, configured to display the target object set in the command line interface;
[0092] A request sending unit, configured to receive an interaction operation on the target object set based on the command line interface, and send a connection information acquisition request for the target container to the container management system based on the interaction operation;
[0093] A connection information receiving unit, configured to receive the connection information of the target container sent by the container management system.
[0094] Optionally, the device further includes:
[0095] A buffer creation module for creating an input / output buffer corresponding to the command line interface and connecting the standard input stream of the system to the input / output buffer, where the data in the input / output buffer is used for display in the command line interface;
[0096] Among them, the container access module includes:
[0097] A command storage unit for obtaining a second command input by the user based on the command line interface from the standard input stream of the system and storing the second command in the input / output buffer;
[0098] A command sending unit for sending the second command stored in the input / output buffer to the target container through the network socket connection in response to a preset sending operation;
[0099] A content update unit for updating the display content in the command line interface according to the return data of the target container.
[0100] Optionally, the content update unit is used to: in response to the return data of the target container including data to be displayed, store the data to be displayed in the input / output buffer and display the data to be displayed in the command line interface; and / or, in response to the return data of the target container including a control instruction, update the display content in the command line interface based on the control instruction.
[0101] Optionally, the container access module is used to: receive a second command based on the command line interface; in response to the second command including a preset control character, perform an interaction operation corresponding to the preset control character with the target container through the network socket connection based on the preset control protocol corresponding to the preset control character.
[0102] Optionally, the preset control protocol includes a file transfer control protocol, and the preset control character includes a file upload control character and / or a file download control character;
[0103] Among them, in response to the second command including a preset control character, performing an interaction operation corresponding to the preset control character with the target container through the network socket connection based on the preset control protocol corresponding to the preset control character includes: in response to the second command including a file upload control character or a file download control character, displaying a file operation window on the upper layer of the command line interface; in response to a file selection operation input based on the file operation window, performing a corresponding file upload operation or file download operation with the target container through the network socket connection based on the file transfer control protocol.
[0104] The container access device provided by the embodiments of the present disclosure can execute the container access method provided by any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects for executing the method.
[0105] It should be noted that the various units and modules included in the above device are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of mutual distinction and do not limit the protection scope of the embodiments of the present disclosure.
[0106] Figure 6 It is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure. The following refers to Figure 6 , which shows a schematic structural diagram of an electronic device 600 suitable for implementing the embodiments of the present disclosure (such as Figure 6 the terminal device or server in). The terminal device in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Tablet Computers), PMPs (Portable Multimedia Players), in-vehicle terminals (such as in-vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and usage scope of the embodiments of the present disclosure.
[0107] As Figure 6 shown, the electronic device 600 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 601, which may execute various appropriate actions and processes according to the program stored in the read-only memory (ROM) 602 or the program loaded from the storage device 608 into the random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. The editing / output (I / O) interface 605 is also connected to the bus 604.
[0108] Generally, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or wiredly to exchange data. Although Figure 6An electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or have all the shown devices. Instead, more or fewer devices may be implemented or had.
[0109] In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, an embodiment of the present disclosure includes a computer program product that includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program codes for performing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network via a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by a processing device 601, the above functions defined in the methods of the embodiments of the present disclosure are performed.
[0110] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are for illustrative purposes only and are not used to limit the scope of these messages or information.
[0111] The electronic device provided in the embodiments of the present disclosure and the container access method provided in the above embodiments belong to the same inventive concept. Technical details not described in detail in this embodiment can be referred to in the above embodiments, and this embodiment has the same beneficial effects as the above embodiments.
[0112] The embodiments of the present disclosure provide a computer storage medium, on which a computer program is stored, and when the program is executed by a processor, it implements the container access method provided in the above embodiments.
[0113] The embodiments of the present disclosure provide a computer program product, including a computer program, and when the program is executed by a processor, it implements the container access method provided in the above embodiments.
[0114] It should be noted that the above-mentioned computer-readable medium in the present disclosure can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in combination with an instruction execution system, apparatus, or device. In the present disclosure, the computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, and this computer-readable signal medium can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0115] The above-mentioned computer-readable medium can be included in the above-mentioned electronic device; it can also exist independently without being assembled into the electronic device.
[0116] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device is caused to: receive a first command based on a command line interface in a preset application program, and obtain connection information of a target container from a container management system based on the first command; establish a network socket connection with the target container based on the connection information; receive a second command based on the command line interface, and interact with the target container through the network socket connection based on the second command.
[0117] Computer program code for performing the operations of this disclosure may be written in one or more programming languages or combinations thereof. The foregoing programming languages include, but are not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or alternatively, may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0118] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a segment of a program, or a portion of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions noted in the blocks may occur in a different order than noted in the drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, or they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0119] The units described in the embodiments of the present disclosure may be implemented in software or in hardware. Among them, the name of the module does not constitute a limitation to the module itself in some cases. For example, the connection establishment module may also be described as "a module for establishing a network socket connection with the target container based on the connection information".
[0120] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, by way of non-limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGA), application specific integrated circuits (ASIC), application specific standard products (ASSP), system on a chip (SOC), complex programmable logic devices (CPLD), and the like.
[0121] In the context of the present disclosure, a machine-readable medium may be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium would include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disc read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0122] According to one or more embodiments of the present disclosure, a container access method is provided, including:
[0123] Receiving a first command based on a command line interface in a preset application program, and obtaining connection information of a target container from a container management system based on the first command;
[0124] Establishing a network socket connection with the target container based on the connection information;
[0125] Receiving a second command based on the command line interface, and interacting with the target container through the network socket connection based on the second command.
[0126] According to one or more embodiments of the present disclosure, the receiving a first command based on a command line interface in a preset application program, and obtaining connection information of a target container from a container management system based on the first command includes:
[0127] Receiving a first command based on a command line interface in a preset application program, and obtaining a set of target objects from a container management system based on the first command, where the set of target objects includes at least one of a set of containers in a target cluster to which the target container belongs, a set of clusters in a target service to which the target cluster belongs, and a set of services to which the target service belongs;
[0128] Displaying the set of target objects in the command line interface;
[0129] Receiving an interaction operation for the set of target objects based on the command line interface, and sending a connection information acquisition request for the target container to the container management system based on the interaction operation;
[0130] Receiving the connection information of the target container sent by the container management system.
[0131] According to one or more embodiments of the present disclosure, it further includes:
[0132] Create an input-output buffer corresponding to the command-line interface, and connect the standard input stream of the system to the input-output buffer, where the data in the input-output buffer is used for display in the command-line interface;
[0133] Among them, receiving a second command based on the command-line interface and interacting with the target container through the network socket connection based on the second command includes:
[0134] Obtain the second command input by the user based on the command-line interface from the standard input stream of the system, and store the second command in the input-output buffer;
[0135] In response to a preset sending operation, send the second command stored in the input-output buffer to the target container through the network socket connection;
[0136] Update the display content in the command-line interface according to the return data of the target container.
[0137] According to one or more embodiments of the present disclosure, updating the display content in the command-line interface according to the return data of the target container includes:
[0138] In response to the return data of the target container including data to be displayed, store the data to be displayed in the input-output buffer and display the data to be displayed in the command-line interface; and / or,
[0139] In response to the return data of the target container including a control instruction, update the display content in the command-line interface based on the control instruction.
[0140] According to one or more embodiments of the present disclosure, receiving a second command based on the command-line interface and interacting with the target container through the network socket connection based on the second command includes:
[0141] Receive a second command based on the command-line interface;
[0142] In response to the second command including a preset control character, perform an interaction operation corresponding to the preset control character with the target container through the network socket connection based on the preset control protocol corresponding to the preset control character.
[0143] According to one or more embodiments of the present disclosure, the preset control protocol includes a file transfer control protocol, and the preset control characters include file upload control characters and / or file download control characters;
[0144] Wherein, in response to the second command including a preset control character, based on the preset control protocol corresponding to the preset control character, an interaction operation corresponding to the preset control character is performed with the target container through the network socket connection, including:
[0145] In response to the second command including a file upload control character or a file download control character, a file operation window is displayed on the upper layer of the command line interface;
[0146] In response to a file selection operation input based on the file operation window, a corresponding file upload operation or file download operation is performed with the target container through the network socket connection based on the file transfer control protocol.
[0147] The above description is only a preferred embodiment of the present disclosure and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosure concept. For example, a technical solution formed by mutually replacing the above features with technical features having similar functions disclosed in the present disclosure (but not limited to).
[0148] In addition, although the operations are depicted in a specific order, this should not be construed as requiring the operations to be performed in the specific order shown or in sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, although several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features described in the context of separate embodiments may also be implemented combinatorially in a single embodiment. Conversely, the various features described in the context of a single embodiment may also be implemented separately or in any suitable sub-combination in multiple embodiments.
[0149] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. On the contrary, the specific features and acts described above are merely example forms of implementing the claims.
Claims
1. A container access method, characterized in that, The method includes: Receiving a first command based on a command-line interface in a preset application, and obtaining connection information of a target container from a container management system based on the first command; Establishing a network socket connection with the target container based on the connection information; Receiving a second command based on the command-line interface, and interacting with the target container through the network socket connection based on the second command.
2. The method according to claim 1, wherein The receiving a first command based on a command-line interface in a preset application, and obtaining connection information of a target container from a container management system based on the first command includes: Receiving a first command based on a command-line interface in a preset application, and obtaining a set of target objects from a container management system based on the first command, where the set of target objects includes at least one of a set of containers in a target cluster to which the target container belongs, a set of clusters in a target service to which the target cluster belongs, and a set of services in a service set to which the target service belongs; Displaying the set of target objects in the command-line interface; Receiving an interaction operation on the set of target objects based on the command-line interface, and sending a connection information acquisition request for the target container to the container management system based on the interaction operation; Receiving the connection information of the target container sent by the container management system.
3. The method according to claim 1, wherein It further includes: Creating an input-output buffer corresponding to the command-line interface, and connecting the standard input stream of the system to the input-output buffer, where the data in the input-output buffer is used for display in the command-line interface; Among them, receiving a second command based on the command-line interface, and interacting with the target container through the network socket connection based on the second command includes: Obtaining a second command input by a user based on the command-line interface from the standard input stream of the system, and storing the second command in the input-output buffer; In response to a preset sending operation, sending the second command stored in the input-output buffer to the target container through the network socket connection; Updating the display content in the command-line interface according to the return data of the target container.
4. The method according to claim 3, characterized in that The updating the display content in the command-line interface according to the return data of the target container includes: In response to the return data of the target container including data to be displayed, storing the data to be displayed in the input-output buffer, and displaying the data to be displayed in the command-line interface; and / or, In response to the return data of the target container including a control instruction, updating the display content in the command-line interface based on the control instruction.
5. The method according to claim 1, wherein Receiving a second command based on the command-line interface, and interacting with the target container through the network socket connection based on the second command includes: Receiving a second command based on the command-line interface; In response to the second command including a preset control character, performing an interaction operation corresponding to the preset control character with the target container through the network socket connection based on a preset control protocol corresponding to the preset control character.
6. The method according to claim 5, characterized in that The preset control protocol includes the File Transfer Control Protocol, and the preset control characters include file upload control characters and / or file download control characters; Wherein, in response to the second command including preset control characters, based on the preset control protocol corresponding to the preset control characters, the following interaction operations corresponding to the preset control characters are performed with the target container through the network socket connection, including: In response to the second command including file upload control characters or file download control characters, a file operation window is displayed on the upper layer of the command line interface; In response to a file selection operation input based on the file operation window, a corresponding file upload operation or file download operation is performed with the target container through the network socket connection based on the File Transfer Control Protocol.
7. A container access device, characterized in that, It includes: A connection information acquisition module, configured to receive a first command based on the command line interface in a preset application program, and acquire connection information of a target container from a container management system based on the first command; A connection establishment module, configured to establish a network socket connection with the target container based on the connection information; A container access module, configured to receive a second command based on the command line interface, and perform interaction with the target container through the network socket connection based on the second command.
8. An electronic device, characterized in that, The electronic device includes: One or more processors; A storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the container access method according to any one of claims 1-6.
9. A storage medium containing computer-executable instructions, characterized in that, The computer-executable instructions are used to execute the container access method according to any one of claims 1-6 when executed by a computer processor.
10. A computer program product, characterized in that, It includes a computer program, and when the computer program is executed by a processor, it implements the container access method according to any one of claims 1-6.