In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how idea integrates docker rapid deployment of springboot applications, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
I. Preface
The word containerization is no stranger to us. When we hear it, we may think of docker, K8s, jenkins, rancher and so on. So today I'm going to talk about how idea uses docker to quickly deploy springboot applications.
II. Environment and tools
Windows10 (Development)
Centos 7.6 (deployment)
Idea
Docker
Xshell
Install docker and configure remote connection
There are many steps to install docker online, so let's say it again here:
Update the wave first.
Sudo yum update
Install the latest docker
Yum install docker-y
Start docker
Systemctl start docker
You can use docker images to view the image status. The following figure indicates that the startup is successful (currently there is no image in it)
If it is shown in the following figure, it means that the startup failed
Open docker remote connection
Edit the docker.service file
Vim / lib/systemd/system/docker.service
When opened, the content is as follows:
On the green cursor line, add the following:
# centos7 and above ExecStart=/usr/bin/dockerd-H tcp://0.0.0.0:2375-H unix://var/run/docker.sock# centos7 below ExecStart=/usr/bin/dockerd-H fd://-H tcp://0.0.0.0:2375
Here I use other ports, such as 12377. After the modification, the content is shown in the following figure:
After saving, reload the configuration file and restart docker:
Systemctl daemon-reload systemctl restart docker
To check if port 12377 is listening, execute lsof-iRanger 12377
If you are using a CVM, you need to enable the 12377 firewall rule. If you use the default port 2375, it doesn't matter if you use a virtual machine or private network. If you are exposed to the public network, you will probably find that your cpu is full the next day and a large number of horse and mining programs are installed. Students who have time can further configure the security configuration. You can search here by yourself.
4. Idea connects to remote docker
Install the plug-in docker
Configure connection
After installation, find the following location in setting
Configure your docker address in TCP socket in the following format:
Tcp://ip:12377, after filling in, wait a little while, the connection test will be carried out below. After the connection is successful, it will be shown in the figure above. 5. Springboot project configuration docker pom configuration
The current project packaging method of the blogger is jar package, and the properties configuration in pom is as follows
Springboot
The configuration in build is as follows:
Docker-demo org.springframework.boot spring-boot-maven-plugin ${spring-boot.version} com.spotify docker-maven-plugin 1.0.0 Http://ip:12377 ${docker.image.prefix} / ${project.artifactId} src/main/docker / ${project.build.directory} ${project.build.finalName} .jar
Resources is to find the typed jar,dockerDirectory. To find the Dockerfile,imageName configured in the project is the image name.
Create Dockerfile (note that Dockerfile is not named for hump)
The structure is shown in the following figure
Contents of Dockerfile file:
The FROM williamyeh/java8 # source can use docker search java8 to search for the first source VOLUME / tmpADD docker-demo.jar / app/docker-demo.jar#COPY target/demo-0.0.1-SNAPSHOT.jar app.jarENTRYPOINT ["java", "- jar", "/ app/docker-demo.jar"]
FROM: specify the basic image, which must be the first command
VOLUME: used to specify the persistence directory
ADD: add local files to the container, tar type files will be automatically extracted (network compressed resources will not be decompressed), can access network resources, similar to wget
ENTRYPOINT: configure the container to make it executable
The rest of the instructions can be searched by themselves.
At this point, the required configuration is complete, and then start running
Find the maven window on the right side of idea and execute clean
Execute package to package after clean is finished.
Then execute the docker:build shown in the figure
In this process, a docker folder is created under the target directory, and the Dockerfile file and the generated jar package are copied, then the basic image is pulled according to the configuration in Dockerfile, and the jar is transferred to the specified location on the server, and then the image is created. Click Services at the bottom of idea after BUILD SUCCESS
The window is as follows
Double-click Docker to connect. After the connection is successful, we can see the health status of the image and container:
Then you can right-click the springboot/**:latest image to create the container
Pop up the create option to create a configuration
Configure the container name and run options inside, and finally click run to run the container. We can see the container's running log in the Services window:
These are all the contents of the article "how idea integrates docker to rapidly deploy springboot applications". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.