Miscellaneous Notes | Use idea to build SpringBoot project and remotely connect to docker to run


Overview

Using docker to run SpringBoot projects is a good choice. The traditional method requires manual packaging and uploading to the server, then using docker build to build the image, and then using docker run to start and run, which is inevitably a bit cumbersome. This article introduces how to use idea to help us complete these operations. Simplify operational procedures.

01 Connect to remote docker

Insert image description here
(As shown in the picture above) Generally, a Docker is provided by default. If not, click the + sign to create a Docker Connection.

Insert image description here
If there is a Dokcer connection, right-click to edit configuration.

Insert image description here
Whether you are adding or editing a configuration, choose SSHthe method

Insert image description here
Enter the server's IP, username and password to create an SSH connection.

After creating it, click the Connect button. (Picture below)
Insert image description here
Insert image description here
In this way, you can connect to the server and manage docker.

02 Local packaging

Insert image description here
Click on the maven management tool on the right, and then click on skip testing above skip tests model.
Then double-click cleanto clear the existing target, and then double-click packageto package.

After success, you can see the project's jar package on the left:
Insert image description here

03 Create dockerfile

In the root directory of the project (that is, the directory at the same level as pom.xml), create a dockerfile file.
Insert image description here
Insert image description here
Fill it in according to your own project situation, this picture is for reference only.

04 Deploy and run

Click the triangle symbol in the upper left corner of the Dockerfile editing interface to run the container.
Insert image description here
Configure the running parameters first, and then run:
Insert image description here
Insert image description here
there is no command line in the whole process, which is quite good.
You can explore more detailed usage by yourself.

Guess you like

Origin blog.csdn.net/xuzhongyi103/article/details/131545343