1. Docker enables remote access[root@izwz9eftauv7x69f5jvi96z docker]# vim /lib/systemd/system/docker.service #Modify the ExecStart line ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock #Reload the configuration file [root@izwz9eftauv7x69f5jvi96z docker]# systemctl daemon-reload #Restart service [root@izwz9eftauv7x69f5jvi96z docker]# systemctl restart docker.service #Check if the port is open [root@izwz9eftauv7x69f5jvi96z docker]# netstat -nlpt #Directly curl to see if it works [root@izwz9eftauv7x69f5jvi96z docker]# curl http://127.0.0.1:2375/info 2. Install Docker plugin in Intellij 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. 3. Spring boot service Docker deployment3.1 Create a new Spring boot project and write a test interface 3.2 Modify the pom file, add properties, and add plugin <properties> <java.version>1.8</java.version> <docker.image.prefix>bozai</docker.image.prefix> </properties> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <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> 3.3 Configure the Dockerfile file: Create a new Dockerfile file in the project root directory. The content is as follows: FROM java:8 VOLUME /tmp COPY target/demo-0.0.1-SNAPSHOT.jar demo.jar RUN bash -c "touch /demo.jar" EXPOSE 8080 ENTRYPOINT ["java","-jar","demo.jar"] 4. 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. Once completed, execute this command: After successful execution, you can see this image on the remote docker: Execute docker ps to see that the image has produced a container and started running: Open the browser and access the test: refer to:https://my.oschina.net/wuweixiang/blog/2874064 https://blog.csdn.net/sealir/article/details/81200662 docker-maven-plugin plugin: https://blog.csdn.net/weixin_44424668/article/details/104062822 This is the end of this article about the steps to quickly implement Docker image deployment in Intellij IDEA. For more relevant IDEA Docker image deployment content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
Table of contents Preface question Online solutio...
Table of contents Enter the topic mysql add, dele...
When using nginx as a reverse proxy, you can simp...
This article uses an example to illustrate the us...
Icon icon processing solution The goal of this re...
Just add the following code to achieve it. Method ...
Linux system version: CentOS7.4 MySQL version: 5....
There are obvious differences between volume moun...
To display the JSON data in a beautiful indented ...
9 great JavaScript framework scripts for drawing ...
The installation tutorial of mysql 8.0.11 winx64 ...
Preface DISTINCT is actually very similar to the ...
Add an input file HTML control to the web page: &...
Preface My needs are syntax highlighting, functio...
Lots of links You’ve no doubt seen a lot of sites ...