The use of plug-in idea inside docker package deployed to achieve SpringBoot project Docker containers on Ali cloud server and run

The use of plug-in idea inside docker package deployed to achieve SpringBoot project Docker containers on Ali cloud server and run

Why Docker

Docker ah really is a good thing, since used it, what things I want to put Wang Libian children, whether nginx solr mysql redis these, all put inside the child, and the management is very good management, deployment is also very convenient, in fact, plainly It is a lazy, ha ha ha ha ha ha ha ha ha ha belch, I believe that the students have been used to put it down, and for the students will not use the recommendations as soon as possible to start! I will not here bb Docker spicy, plenty of information online, I just start this theme now!

Docker plug-in installation

File > Settings > Plugins > Docker

General idea is automatically installed to give us a good, you can directly use, but does not rule out some special cases

Here Insert Picture Description

Docker connection

Docker Ali deployed on a cloud server and ensure that normal operation in /usr/lib/systemd/system/doker.servicethe configuration file inside to make some changes
Here Insert Picture Description
found ExecStart in 18 rows behind the first row plus

-H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock \

Below the picture becomes sub-sub

Here Insert Picture Description

Save and exit, and about the implementation of two commands

systemctl daemon-reload 
systemctl restart docker

After successful execution restart docker

Open ports

Docker because there is a communication port by 2375, so we have to open port 2375 in Ali cloud server security group inside

Here Insert Picture Description

Construction of Docker connection

找到 File > Settings > Build, Execution, Deployment > Docker

Click the + sign to create open access and change the localhost server behind Engin API URL in this box of public ip

Here Insert Picture Description

The following shows Connection successful it shows the connection is successful, let's be happy spicy continue to go down

Project Package

After the far right to find Maven, open the list, first click on the item clean, cleaned, packed and then point package, it may take more than half a point to get it, after packing down the left targer directory will have a jar package, By the time we put this jar package is thrown into the container to go inside and run

Create a file Dockerfile

Here Insert Picture Description

Then create Dockerfile profile in the project root directory and enter the appropriate content in it according to the situation

# 使用java环境
FROM java
# 缓存目录
VOLUME tmp
# 将当前项目的jar包添加到容器中
ADD "target/pms-0.0.1-SNAPSHOT.jar" "RestHome.jar"
# 当容器启动时 执行启动命令
ENTRYPOINT ["java","-jar","RestHome.jar"]

"RestHome.jar" RestHome custom name can be changed

Create a profile

Click on the top right corner of the Edit Configurations and New Dockerfile configuration and are configured in the picture provided below

  1. Here Insert Picture Description

  2. Here Insert Picture Description

  3. Here Insert Picture Description

All this inside information can be filled in accordance with their own needs, just fill in the most basic content I have here, but it is worth noting that the port here write their own port project is currently in the Run options, otherwise error-prone, as the What is the problem, we have to wait to know the students go around, Hey Hey. After configuration, click Apply and then OK

Execution profile

Click just to the right of the position of the green triangle configuration file to run, will wait here for some time, and finally we see the success of the project started from the console, that success, we go inside the children look at server

Here Insert Picture Description
nice baby, the whole project package SpringBoot Docker and deployed to run such a process is complete, it is not particularly simple? What problems can interact in the comments section oh

Published 30 original articles · won praise 7 · views 1561

Guess you like

Origin blog.csdn.net/qq_41946543/article/details/103965058