1. IntroductionI believe everyone is familiar with the term containerization. When we hear it, we may think of docker, k8s, jenkins, rancher, etc. So today I will talk about how idea uses docker to quickly deploy springboot applications. 2. Environment and Tools
3. Install Docker and configure remote connectionThere are many steps to install Docker on the Internet, so let’s talk about them again here: Update first
Install the latest docker
Start Docker
You can use If it is as shown below, it means startup failed Open docker remote connection and edit the docker.service file
After opening, the content is as follows: Add the following to the line with the green cursor: # 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 change, the content is as shown below: After saving, reload the configuration file and restart Docker: systemctl daemon-reload systemctl restart docker To check whether port 12377 is being listened, execute If you are using a cloud server, you need to enable the 12377 firewall rule. If you use the default port 2375, it doesn't matter if it is only used in a virtual machine or intranet. If it is 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 mounted. Students who have time can further configure the security configuration. You can search it here. 4. idea connects to remote docker Install the docker plugin After the configuration connection is installed, find the location in the setting as shown below Configure your docker address on the TCP socket in the following format: <properties> <!--Set the prefix of the docker image in the properties node "springboot" --> <docker.image.prefix>springboot</docker.image.prefix> </properties> The build is configured as follows: <build> <finalName>docker-demo</finalName> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>${spring-boot.version}</version> </plugin> <plugin> <!-- docker-maven plugin --> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>1.0.0</version> <configuration> <dockerHost>http://ip:12377</dockerHost> <imageName>${docker.image.prefix}/${project.artifactId}</imageName> <dockerDirectory>src/main/docker</dockerDirectory> <resources> <resource> <targetPath>/</targetPath> <directory>${project.build.directory}</directory> <include>${project.build.finalName}.jar</include> </resource> </resources> </configuration> </plugin> </plugins> </build> resources is to find the packaged jar, dockerDirectory is to find Create a Dockerfile (note that the Dockerfile is not camel case) Dockerfile file content: FROM williamyeh/java8 # The source can be searched using docker search java8. VOLUME /tmp ADD docker-demo.jar /app/docker-demo.jar #COPY target/demo-0.0.1-SNAPSHOT.jar app.jar ENTRYPOINT ["java", "-jar", "/app/docker-demo.jar"] FROM : specifies the base image, must be the first command
After clean is completed, execute package to package Then execute docker:build as shown in the figure In this process, a docker folder will be created in the target directory, and the Dockerfile file and the generated jar package will be copied. Then, according to the configuration in the Dockerfile, the base image will be pulled, the jar will be transferred to the specified location of the server, and then the image will be made. After BUILD SUCCESS, click The window is as follows Double-click Docker to connect. After the connection is successful, we can see the image and container running status: Then you can right-click the springboot/**:latest image to create a container The create option pops up to create the configuration Configure the container name and run options, and finally click Run to run the container. In the Services window we can see the container's running log: So far, the idea of integrating docker to quickly deploy springboot applications has been completed. I will summarize the use of jenkins+k8s+docker later. This is the end of this article about idea integration docker quick deployment of springboot application. For more related idea docker deployment springboot content, please search 123WORDPRESS.COM previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: MYSQL's 10 classic optimization cases and scenarios
>>: Review of the best web design works in 2012 [Part 1]
This CSS reset is modified based on Eric Meyers...
Docker official documentation: https://docs.docke...
Detailed example of clearing tablespace fragmenta...
[Usage and function of mysql cursor] example: The...
Table of contents 1. Register an account on Baidu...
Table of contents one. environment two. Precautio...
Table of contents Preface HTTP HTTP Server File S...
There are many tags and elements in the HTML head ...
Learn how to host your own website on Apache, a r...
My recommendation Solution for coexistence of mul...
1. Introduction table_cache is a very important M...
How to center an element in the browser window He...
Use regular expressions to determine the IE browse...
A docker container state transition diagram Secon...
When installing a virtual machine, a prompt appea...