Idea deploys remote Docker and configures the file

Idea deploys remote Docker and configures the file

1. Modify the Linux server docker configuration file

vim /usr/lib/systemd/system/docker.service

Add Configuration

ExecStart=/usr/bin/dockerd

-H fd:// --containerd=/run/containerd/containerd.sock

-H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock

Restart Docker

systemctl daemon-reload

systemctl restart docker

2. Idea downloads the docker plugin

3. Modify the project pom file

 <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.4.1</version>
 
                <configuration>
                    <fork>true</fork>
                    <addResources>true</addResources>
                    <mainClass>com.Main8090</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>1.0.0</version>
                <!--Bind the plugin to a certain phase for execution-->
                <executions>
                    <execution>
                        <id>build-image</id>
                        <!--Bind the plug-in to the package phase. That is to say, users only need to execute mvn package, which will automatically execute mvn docker:build-->
                        <phase>package</phase>
                        <goals>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <!--Specify the generated image name ${project.artifactId} -->
                    <imageName>idea2021test</imageName>
                    <!--Specify tags-->
                    <imageTags>
                        <imageTag>latest</imageTag>
                    </imageTags>
                    <!-- Specify the Dockerfile path ${project.basedir}: under the project root path -->
                    <dockerDirectory>${project.basedir}</dockerDirectory>
                    <!--Specify the remote docker api address-->
                    <dockerHost>http://101.200.201.196: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>
                    <!-- The following two lines are used for docker push to DockerHub. -->
                    <!--<serverId>docker-hub</serverId>-->
                    <!--<registryUrl>https://index.docker.io/v1</registryUrl>-->
                </configuration>
            </plugin>
        </plugins>
    </build>

4. Packaging and building

---> Running in 0ff0ece2e746
Removing intermediate container 0ff0ece2e746
---> 76846947b2eb
Step 4/4 : ENTRYPOINT ["java","-jar","/app.jar"]

---> Running in fac72c653afd
Removing intermediate container fac72c653afd
---> f7866a998d4e
ProgressMessage{id=null, status=null, stream=null, error=null, progress=null, progressDetail=null}
Successfully built f7866a998d4e
Successfully tagged idea2021test:latest
[INFO] Built idea2021test
[INFO] Tagging idea2021test with latest
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:43 min
[INFO] Finished at: 2021-06-17T21:02:25+08:00

Indicates that the build was successful

5. Create a container

6. Configure the mapping port

7. Run

This is the end of this article about Idea configuration Docker remote deployment. For more related idea deployment remote docker content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Steps for IDEA to integrate Docker to achieve remote deployment
  • Detailed steps for IDEA to integrate docker to achieve remote deployment
  • How to use Docker plugin to remotely deploy projects to cloud servers in IDEA
  • Detailed tutorial on how to connect to a remote server Docker to deploy a Spring Boot project in IDEA
  • Java remote one-click deployment of springboot to Docker through Idea
  • Implementation of IDEA remote management of docker images and container services

<<:  Solve the problem of Navicat for MySQL reporting 2005 error when connecting to MySQL

>>:  26 Commonly Forgotten CSS Tips

Recommend

How to remove the dotted border when clicking a link in FireFox

I encountered several browser compatibility issue...

Example of how to deploy MySQL 8.0 using Docker

1. Refer to the official website to install docke...

Vue Getting Started with Weather Forecast

This article example shares the specific code of ...

Sample code for installing ASPNET.Core3.0 runtime in Linux

# The following examples are for x64-bit runtime ...

How to stop CSS animation midway and maintain the posture

Preface I once encountered a difficult problem. I...

Analysis of the use of the MySQL database show processlist command

In actual project development, if we have a lot o...

Implementing a simple carousel based on JavaScript

This article shares the specific code of JavaScri...

Summary of several key points about mysql init_connect

The role of init_connect init_connect is usually ...

A brief analysis of React's understanding of state

How to define complex components (class component...

Ubuntu 18.04 installs mysql 5.7.23

I installed MySQL smoothly in Ubuntu 16.04 before...

js realizes the function of clicking to switch cards

This article example shares the specific code of ...

Perfect Solution for No rc.local File in Linux

Newer Linux distributions no longer have the rc.l...

js implementation of verification code case

This article example shares the specific code of ...

W3C Tutorial (7): W3C XSL Activities

A style sheet describes how a document should be ...