1. IDEA downloads the docker plug-inI won’t go into details here, just install it like other plugins 2. Cloud Server DockerNote: My server uses centOS 7 2.1 Docker installationhttps://www.jb51.net/article/213611.htm 2.2 Stop Docker ServiceTo prevent errors when restarting the Docker service, it is best to stop the Docker service first and then modify the configuration file. Before stopping Docker, you must stop the running container first, otherwise errors may occur when starting the container later. Stop the running container:
Then stop the docker service
2.3 Docker configuration file modificationIn order to use HTTP to connect IDEA to the docker on the server, you need to modify the docker configuration file as follows:
Modify the Execstart line and replace it with the following content to open port 2375 for HTTP remote connections:
2.4 Refresh the configuration fileThe command is as follows:
To test whether the configuration file is effective, enter the following command on the server. If the JSON string content appears, the file is effective.
2.5 Start the Docker serviceThe command is as follows:
2.6 Add port 2375 to the firewallThe command is as follows:
Restart the firewall:
2.7 Alibaba Cloud adds security group rulesHere, please note that you need to enter the security group on the instance page, then configure the rules and open port 2375. 2.8 Testing remote HTTP connection Enter At this point, you can use IDEA to integrate dokcer. 3. Maven project packaging3.1 Packaging pluginsAdd the springboot packaging plug-in to the pom file <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> 3.2 Packaging of resource files and their location after packagingIn addition to packaging Java source files, you also need to package resource files, such as XML/YML/Properties/HTML files. But pay attention to the location where the HTML file is packaged. It should be placed in the META-INF/resources directory. Otherwise, the HTML page cannot be accessed after starting the jar package. <resources> <resource> <directory>src/main/java</directory> <!--Here I put the mapper file in the java directory so I need to declare the compilation location--> <includes> <include>**/*.xml</include> </includes> <filtering>true</filtering> </resource> <resource> <!--Declare the compile location of the yml configuration file--> <directory>src/main/resources</directory> </resource> <resource> <!--Declare the HTML file compilation location and put the compiled file into the specified location--> <directory>src/main/webapp</directory> <targetPath>META-INF/resources</targetPath> </resource> </resources> 3.3 Docker pluginThere are two things to note. First, there needs to be a prefix in front of the Docker image name, which is composed of [prefix]:[image name]:[version number]. Second, uppercase letters must not be included when specifying the image name. Both name and version are used in project information <groupId>org.team</groupId> <artifactId>coolmeeting</artifactId> <version>1.0-SNAPSHOT</version> <name>coolmeeting</name> <description>docker start meetingMS</description> <properties> <java.version>1.8</java.version> <docker.image.prefix>team</docker.image.prefix> </properties> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <!-- tag::plugin[] --> <plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>1.0.0</version> <configuration> <dockerHost>http://127.0.0.1:2375</dockerHost> <!--Image name cannot contain uppercase letters--> <imageName>${docker.image.prefix}/${project.artifactId}</imageName> <!--Dockerfile location--> <dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory> <resources> <resource> <targetPath>/</targetPath> <!--target location--> <directory>${project.build.directory}</directory> <!--Put the jar package and Dockerfile in the same directory--> <include>${project.build.finalName}.jar</include> </resource> </resources> </configuration> </plugin> <!-- end::plugin[] --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skipTests>true</skipTests> </configuration> </plugin> </plugins> The Dockerfile file is as follows. Note that D should be capitalized when creating the file. /meetingMS.jar is an alias for easy writing. FROM java:8 VOLUME /tmp ADD coolmeeting-1.0-SNAPSHOT.jar /meetingMS.jar ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/meetingMS.jar"] 3.4 clean, install and docker buildFirst use Maven to clean and install, then use the Maven plugin docker to build The packaged file directory: Start the container Set startup parameters 4. Pitfalls encountered
5. References Springboot packaged as jar cannot access jsp or html, 404 error About yml or properties files not being scanned Specify the startup port when running the Jar package stackover IDEA integrates Docker to quickly deploy SpringBoot applications IDEA integrates Docker for quick deployment This is the end of this article about IDEA integrating docker to deploy springboot project. For more relevant IDEA integrating docker to deploy springboot project content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: CSS tips for controlling animation playback and pause (very practical)
>>: Three common ways to embed CSS in HTML documents
I have never used apache. After I started working...
In a word: if you buy a cloud server from any maj...
1. Install MySQL # Download mysql in docker docke...
When developing a web project, you need to instal...
Table of contents 1. Affairs: Four major characte...
CSS style specifications 1. Class Selector 2. Tag...
Preface tcpdump is a well-known command-line pack...
Detailed tutorial on downloading and installing M...
Mongodb has a db.serverStatus() command, which ca...
one. Overview of IE8 Compatibility View <br /&...
Table of contents background Server Dependencies ...
1. To optimize the query, try to avoid full table...
1. Installation version details Server: MariaDB S...
The default storage directory of mysql is /var/li...
What I bring to you today is to use jQuery to imp...