1. Modify the docker configuration file and open port 2375 [root@s162 docker]# vim /usr/lib/systemd/system/docker.service #Find ExecStart, add # at the end and add -H tcp://0.0.0.0:2375 [root@s162 docker]# systemctl daemon-reload [root@s162 docker]# systemctl start docker ## Check whether port 2375 is enabled [root@s162 docker]# lsof -i:2375 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME dockerd 27021 root 5u IPv6 352598799 0t0 TCP *:2375 (LISTEN) 2. Idea installation and configuration of docker plug-in 2.1. Install the docker plugin from the idea-plugins market slightly… 2.2. Configure Docker 3. Deploy the springboot project to the docker server 3.1. Writing docker/dockerfile 3.2. Maven adds docker-maven-plugin plug-in <plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>1.0.0</version> <configuration> <!--Specify the generated image name. If you do not specify a tag, the default will be to use the latest--> <imageName>jhs/${project.artifactId}:${project.version}</imageName> <!--Add additional specified tags, not required--> <!-- <imageTags> <imageTag>${project.version}</imageTag> </imageTags> --> <!-- Specify the Dockerfile path: under the project root path --> <dockerDirectory>${project.basedir}/docker</dockerDirectory> <!--Specify the remote docker api address--> <dockerHost>http://192.168.129.162:2375</dockerHost> <!-- copy resources --> <resources> <resource> <targetPath>/</targetPath> <directory>${project.build.directory}</directory> <include>${project.build.finalName}.jar</include> </resource> </resources> <!--When docker build dockerfile: set variables when creating the image --> <buildArgs> <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE> </buildArgs> </configuration> </plugin> 3.3. docker:build Use the command 3.4 docker:tag
Plugin Configuration <configuration> <image>jhs/${project.artifactId}:${project.version}</image> <!-- docker tag --> <newName>192.168.129.160:5000/${project.artifactId}:${project.version}</newName> </configuration> Tag the image to prepare for the subsequent push: 3.5 docker:push Plugin Configuration <configuration> <!-- docker push pushes to the remote image repository--> <!-- serverId: is the server information id configured in maven setting.xml--> <serverId>nexus-docker-registry</serverId> <registryUrl>192.168.129.160:5000</registryUrl> <!-- Push the new image with tag to Nexus--> <imageName>192.168.129.160:5000/${project.artifactId}</imageName> </configuration> Push the image tagged above to the private server nexus: 3.6 Docker plugin parameters
3.7 Binding commands to Maven phases <executions> <execution> <id>build-image</id> <phase>package</phase> <goals> <goal>build</goal> </goals> </execution> <execution> <id>tag-image</id> <phase>package</phase> <goals> <goal>tag</goal> </goals> <configuration> <image>jhs/${project.artifactId}:${project.version}</image> <newName>192.168.129.160:5000/${project.artifactId}:${project.version}</newName> </configuration> </execution> <execution> <id>push-image</id> <phase>deploy</phase> <goals> <goal>push</goal> </goals> <configuration> <!-- docker push pushes to the remote image repository--> <!-- serverId: is the server information id configured in maven setting.xml--> <serverId>nexus-docker-registry</serverId> <registryUrl>192.168.129.160:5000</registryUrl> <imageName>192.168.129.160:5000/${project.artifactId}</imageName> </configuration> </execution> </executions> 3.8 Best Practices <properties> <docker.host>http://192.168.129.162:2375</docker.host> <docker.registry.url>192.168.129.160:5000</docker.registry.url> </properties> <build> <plugins> <plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>1.0.0</version> <configuration> <imageName>dic/${project.artifactId}:${project.version}</imageName> <!--Add additional specified tags (multiple tags can be configured), if not specified, it will be latest--> <!-- <imageTags> <imageTag>${project.version}</imageTag> </imageTags> --> <!-- Specify the Dockerfile path: under the project root path --> <dockerDirectory>${project.basedir}/docker</dockerDirectory> <!--Specify the remote docker api address--> <dockerHost>${docker.host}</dockerHost> <!-- copy resources --> <resources> <resource> <targetPath>/</targetPath> <directory>${project.build.directory}</directory> <include>${project.build.finalName}.jar</include> </resource> </resources> <!--When docker build dockerfile: set variables when creating the image --> <buildArgs> <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE> </buildArgs> </configuration> <executions> <execution> <id>build-image</id> <phase>package</phase> <goals> <goal>build</goal> </goals> </execution> <execution> <id>tag-image</id> <phase>package</phase> <goals> <goal>tag</goal> </goals> <configuration> <image>dic/${project.artifactId}:${project.version}</image> <newName>${docker.registry.url}/${project.artifactId}:${project.version}</newName> </configuration> </execution> <execution> <id>push-image</id> <phase>deploy</phase> <goals> <goal>push</goal> </goals> <configuration> <!-- docker push pushes to the remote image repository--> <!-- serverId: is the server information id configured in maven setting.xml--> <serverId>nexus-docker-registry</serverId> <registryUrl>${docker.registry.url}</registryUrl> <imageName>${docker.registry.url}/${project.artifactId}</imageName> </configuration> </execution> </executions> </plugin> </plugins> </build> 4. Detailed steps for installing Harbor, a private Docker repository (supplement) https://www.jb51.net/article/161964.htm This is the end of this article about idea connecting docker to achieve one-click deployment. For more related idea connecting docker to achieve one-click deployment, 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:
|
<<: Detailed explanation of MySQL alter ignore syntax
>>: Element Table table component multi-field (multi-column) sorting method
In this article we assume you already know the ba...
Preface Recently, a Java EE web project that has ...
Description of port availability detection when p...
Sometimes you need to use links, but you don't...
For more exciting content, please visit https://g...
React tsx generates a random verification code fo...
Implementation effect: 1. count(1) and count(*) W...
The development of Docker technology provides a m...
Problem Peeping In the server, assuming that the ...
Table of contents What is async? Why do we need a...
Table of contents Preface Virtual DOM What is Vir...
In daily operation and maintenance work, nginx se...
“How to make a website look high-end? Or more des...
Before reading this article, I hope you have a pr...
Table of contents Preface 1. Key Elements of a Re...