1. Enable remote access to the docker server Log in to the remote server where docker is located, and use the command
#ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock After saving the configuration file, you need to reload the configuration and restart Docker. You can use the following command systemctl daemon-reload systemctl restart docker.service 2. Install the docker plugin in IDEAGenerally, newer IDEAs are bound to the docker plug-in. If it is not bound, search and install the docker plug-in in IDEA's Plugins. After installation, restart the system to take effect. After restarting, you can Build, Execution, Depolyment ——> Docker path to find the Docker plug-in, and then add a new configuration to connect to the remote Docker After the connection is successful, you can view the image and container of the remote Docker host in the IDEA plug-in panel, as well as the log of the container operation and other information. 3. Docker image build and uploadTo build the locally packaged jar into a docker image, you need to add a build plugin configuration in the project pom file. The following is a packaging configuration of a SpringBoot project module. The key points are as follows: Build a jar package named <build> <finalName>nathan-api</finalName> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.4.2</version> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>1.1.0</version> <!--Bind the plugin to a certain phase for execution--> <executions> <execution> <id>build-image</id> <!--Users only need to execute mvn package, and mvn docker:build will be automatically executed--> <phase>package</phase> <goals> <goal>build</goal> </goals> </execution> </executions> <configuration> <!--Specify the docker file directory--> <dockerDirectory>${project.basedir}/docker</dockerDirectory> <!--Specify the generated image name--> <imageName>${project.artifactId}</imageName> <!--Specify tags--> <imageTags> <imageTag>latest</imageTag> </imageTags> <!--Specify the remote docker api address--> <dockerHost>http://xxx.168.146.63:2375</dockerHost> <!-- Here is the configuration for copying the jar package to the specified directory of the docker container--> <resources> <resource> <targetPath>/</targetPath> <!--The path where the jar package is located corresponds to the target directory --> <directory>${project.build.directory}</directory> <!-- The jar package that needs to be included, which corresponds to the file name added in Dockerfile--> <include>${project.build.finalName}.jar</include> </resource> </resources> </configuration> </plugin> </plugins> </build> In the previous step, the directory of the docker file was configured in the docker maven plugin, and FROM java:8 VOLUME /tmp # Copy the packaged jar to app.jar ADD nathan-api.jar app.jar EXPOSE 20561 # The following is the jar package startup command configuration ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom","-Duser.timezone=GMT+8", "-jar", "app.jar"] After the above configuration, the action of building the docker image has been bound to the maven
After the docker image is built, right-click the image file and choose to create a container. The simplest step to create a new container is to name the container, then add the port mapping from the host to the container. After the creation is successful, the container will automatically run. This is the end of this article about the detailed steps of IDEA integrating docker to achieve remote deployment. For more relevant IDEA remote 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:
|
<<: Detailed introduction and usage examples of map tag parameters
>>: WeChat applet uniapp realizes the left swipe to delete effect (complete code)
Adobe Brackets is an open source, simple and powe...
The most common mistake made by many website desi...
Preview knowledge points. Animation Frames Backgr...
Table of contents 1. Introduction to gojs 2. Gojs...
Table of contents 1. Object properties 1.1 Attrib...
Table of contents 1. Retrieve the image 2. Create...
UPD 2020.2.26 Currently Ubuntu 20.04 LTS has not ...
1. The organizational structure of the hypertext d...
Recently, many students have asked me about web p...
Install GeoIP on Linux yum install nginx-module-g...
Cocos Creator modular script Cocos Creator allows...
This article shares the specific code of Javascri...
I recently used the MySql database when developin...
First, pull the image (or just create a container...
This CSS reset is modified based on Eric Meyers...