1. Development Environment
2. Install the docker plugin1. Installation in IdeaOpen Idea, go to File->Settings->Plugins->Install JetBrains plugin to enter the plugin installation interface, enter docker in the search box, you can see Docker integration, click the Install button on the right to install it. Restart Idea after installation. After restarting, configure docker and connect to the remote docker service. Open the configuration interface from File->Settings->Build,Execution,Deployment->Docker. Click the + sign to add a docker configuration, enter the Name and Engine API URL. The URL is the docker service address, and docker needs to enable the remote connection function. In CentOS, add the following configuration to the docker startup parameters to enable remote connection. Configuration file location: /usr/lib/systemd/system/docker.service, configuration parameter item: ExecStart -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375 2. Download the installation package and install itDownload the docker installation package from the JetBrains official website (http://plugins.jetbrains.com/plugin/7724-docker-integration), open Idea after downloading, open the file selection interface from File->Settings->Plugins->Install plugin from disk, select the zip installation package you just downloaded, and restart Idea after installation. The configuration is as above. 3. Spring Boot service docker deployment1. Create a new Spring Boot projectYou can refer to the sample project https://github.com/sealire/people/tree/tutorial and write a REST interface in the project as follows, which simply returns a string. @RequestMapping(value = "test", method = RequestMethod.GET) @ResponseBody public Object test(HttpServletRequest request, @RequestParam String param) { return param; } Modify the pom file, add properties, and add plugin: <properties> <docker.image.prefix>leesia</docker.image.prefix> </properties> <build> <plugins> <plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>1.0.0</version> <configuration> <imageName>${docker.image.prefix}/${project.artifactId}</imageName> <dockerDirectory></dockerDirectory> <resources> <resource> <targetPath>/</targetPath> <directory>${project.build.directory}</directory> <include>${project.build.finalName}.jar</include> </resource> </resources> </configuration> </plugin> </plugins> </build> 2. Configure the Dockerfile fileCreate a new Dockerfile file in the project root directory with the following content: FROM java:8 VOLUME /tmp COPY target/resource-1.0-SNAPSHOT.jar resource.jar RUN bash -c "touch /resource.jar" EXPOSE 8080 ENTRYPOINT ["java","-jar","resource.jar"] # docker run -d -p 18080:8080 --name docker-resource leesia/resource:1.0 The base image is java:8, and the copy command copies the resource jar under /target to the image. ENTRYPOINT is the command to start the container. 3. Create a Docker imagePackage the project and execute the mvn clean package command in the idea Terminal to compile and package it. After packaging, a jar package will be generated in the target directory. After generating the jar package, you can start the service locally for testing. After testing, configure the Docker image creation command. Enter the configuration interface from Run->Edit Configrations. Click Docker, then click the + sign, add a docker command, enter Name, select Server, select the Dockerfile file, enter the image tag, and complete the configuration. After the configuration is complete, execute this command, If there are no errors, the Docker server will be connected and the image will be created. After creating the image, start the image on the Docker server and execute the following command to start the image: docker run -d -p 18080:8080 --name docker-resource leesia/resource:1.0 -p binds the Docker server's port 18080 to the container's port 8080. After the container is started, access the service interface. The interface parameter is a string and the character is returned. This is the end of this article about installing the docker plugin for IntelliJ IDEA. For more information about installing the docker plugin for IDEA, 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:
|
<<: MySQL date and time addition and subtraction sample code
>>: Example code for CSS pseudo-classes to modify input selection style
1. Remove MySQL a. sudo apt-get autoremove --purg...
Table of contents 1. Introduction 2. Main text 2....
<br />This example mainly studies two parame...
This article is compiled with reference to the My...
Table of contents 1. Create a sql script file con...
In MySQL, fields of char, varchar, and text types...
1. Make sure the network connection method is bri...
What if you designers want to use the font below ...
Adding a network interface to the container 1 Run...
There are two solutions: One is CSS, using backgro...
Table of contents Solution Analysis slice Resume ...
1. First go to the official website https://www.p...
This is not actually an official document of IE. I...
Table of contents Vue monitor properties What is ...
Preface The author has always felt that it would ...