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 1. Boolean 2. Expression 3. Mul...
win10 + Ubuntu 20.04 LTS dual system installation...
We often see a cool effect where the mouse hovers...
Use MySQL proxies_priv (simulated role) to implem...
Preface As we all know, by default, the MySQL ins...
The operating system for the following content is...
Due to some of its own characteristics (locking t...
The browser is probably the most familiar tool fo...
Hexadecimal code table of various colors [Part 1] ...
Document hints using the show-header attribute sh...
Today, let’s get straight to the point and talk a...
It can be referenced through CDN (Content Delivery...
1. Overview I searched a lot online and found tha...
Before hiding: After hiding: CSS: Copy code The co...
Table of contents 1. Database Engine 1.1 View dat...