This article is participating in “Java Theme Month – Java Development in Action”, see the activity link for details

# Replace or modify: 127.0.0.1 (local network access) with 0.0.0.0 to indicate unrestricted access addresses
[root@iZinjout7fetz2Z ~]# vim /usr/lib/systemd/system/docker.service
Copy the code

#reload
[root@iZinjout7fetz2Z ~]# systemctl daemon-reload
#Restart the Docker service
[root@iZinjout7fetz2Z ~]# systemctl restart docker.service
#Viewing Listening Ports
[root@iZinjout7fetz2Z ~]# netstat -lntp | grep dockerd
tcp6       0      0 :::2375                 :::*                    LISTEN      32199/dockerd
Copy the code

<! Change the build address of the project to your own, change the docker API address to your own, specify the name of the generated image before changing the name of your own. 
<build>
        <! -- Quote our project name -->
        <finalName>${project.artifactId}</finalName>

        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>

            <! Docker-maven-plugin -->
            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>1.2.2</version>
                <! -- Bind the plug-in to a phase execution -->
                <executions>
                    <execution>
                        <id>build-image</id>
                        <! Docker :build-->
                        <phase>package</phase>
                        <goals>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>

                <configuration>
                    <! -- Specify the name of the image to be generated, in this case our author name + project name -->
                    <imageName>cainiao/${project.artifactId}</imageName>

                    <! This is the latest version of the image -->
                    <imageTags>
                        <imageTag>latest</imageTag>
                    </imageTags>

                    <! Jdk1.8 -->
                    <baseImage>java</baseImage>
                    <! -- Image producer information <maintainer>[email protected]</maintainer> -->
                    <! -- Switch to ROOT directory -->
                    <workdir>/ROOT</workdir>

                    <! View our Java version -->
                    <cmd>["java", "-version"]</cmd>

                    <! ${project.build.finalName}. Jar is the name of the generated JAR package -->
                    <entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>

                    <! Remote docker API address -->
                    <dockerHost>http://121.196.244.206:2375</dockerHost>

                    <! Docker jar package to docker container -->
                    <resources>
                        <resource>
                            <targetPath>/</targetPath>
                            <! Target directory --> jar package --> jar package --> jar package --> jar package --> jar package --> jar package --> jar package
                            <directory>${project.build.directory}</directory>
                            <! Dockerfile --> jar --> jar --> jar --> jar --> jar
                            <include>${project.build.finalName}.jar</include>
                        </resource>
                    </resources>

                </configuration>
            </plugin>
        </plugins>
    </build>
Copy the code
#Run the terminal command
mvn clean install -Dmaven.test.skip=true
Copy the code
# Run options:  --name meeting -p 8095:8095 -v /home/meeting/logs/:/var/logs/meeting -v /etc/timezone:/etc/timezone -v /etc/localtime:/etc/localtimeCopy the code