Use maven plugin to build micro-mirror services Docker

1. Add a plug-in pom service


                        <plugin>
     <groupId>com.spotify</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <version>0.4.13</version>
    <configuration>
        <imageName>eureka</imageName>
        <dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
        <dockerHost>http://Docker宿主机ip:2375</dockerHost>
        <resources>
            <resource>
                <targetPath>/</targetPath>
                <directory>${project.build.directory}</directory>
                <include>${project.build.finalName}.jar</include>
            </resource>
        </resources>
    </configuration>

</plugin>

2. Add the src / main / docker source folder, and add Dockerfile, content:

FROM java:8


VOLUME /temp


ADD eureka-service-1.0.jar app.jar
RUN bash -c 'touch /app.jar'


EXPOSE 8088


ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]


3. used locally: mvn clean package docker: build -DskipTests

If you're lucky enough, you can build on top of three steps should be mirrored on the server locally. I said the following about a variety of pit encountered! ! !

1) Failed to execute goal com.spotify: docker-maven-plugin: 0.4.13: build (default-cli) on project springb: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded .javax.ws.rs.ProcessingException: org.apache.http.conn.HttpHostConnectException: Connect to localhost: 2375 [localhost / 127.0.0.1, localhost / 0: 0: 0: 0: 0: 0: 0: 1] failed : Connection refused: connect ==== "this problem can be configured in the pom <dockerHost> http: // Docker host ip: 2375 </ dockerHost> to solve, but doing so may quote the following fault, I That's it

2) Failed to execute goal com.spotify:docker-maven-plugin:0.4.13:build (default-cli) on project eureka-service: Exception caught: Timeout: GET http://10.61.213.105:2372135/version: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: org.apache.http.conn.ConnectTimeoutException: Connect to 10.61.213.105:2375 [/10.61.213.105] failed: connect timed out

Here is the solution ==================== ========================== ===========

/usr/lib/systemd/system/docker.service add attributes:

The ExecStart = / usr / bin / dockerd -current into ExecStart = / usr / bin / dockerd -H tcp: //0.0.0.0: 2375 -H unix: //var/run/docker.sock, the original \ to retention and systemctl daemon-reload. Restart docker, telnet success (believe me there are a lot of pit), the effect is as follows:! [Here insert a picture description] (https://img-blog.csdnimg.cn/20200219224008611.png?x-oss-process=image / watermark, type_ZmFuZ3poZW5naGVpdGk, shadow_10, text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl8zMjgyMjc1OQ ==, size_16, color_FFFFFF, t_70)

3) If the above problem persists, there is no need to check the server port to open remote connections, the firewall may need to do some operations that can find some information on the Internet, and finally Good luck, do not use this kind can jenkins way up. . .




)in case

                        <li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#csdnc-thumbsup"></use>
                        </svg><span class="name">点赞</span>
                        <span class="count"></span>
                        </a></li>
                        <li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{&quot;mod&quot;:&quot;popu_824&quot;}"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#icon-csdnc-Collection-G"></use>
                        </svg><span class="name">收藏</span></a></li>
                        <li class="tool-item tool-active is-share"><a href="javascript:;"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#icon-csdnc-fenxiang"></use>
                        </svg>分享</a></li>
                        <!--打赏开始-->
                                                <!--打赏结束-->
                                                <li class="tool-item tool-more">
                            <a>
                            <svg t="1575545411852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg>
                            </a>
                            <ul class="more-box">
                                <li class="item"><a class="article-report">文章举报</a></li>
                            </ul>
                        </li>
                                            </ul>
                </div>
                            </div>
            <div class="person-messagebox">
                <div class="left-message"><a href="https://blog.csdn.net/weixin_41830501">
                    <img src="https://profile.csdnimg.cn/8/E/E/3_weixin_41830501" class="avatar_pic" username="weixin_41830501">
                                            <img src="https://g.csdnimg.cn/static/user-reg-year/1x/2.png" class="user-years">
                                    </a></div>
                <div class="middle-message">
                                        <div class="title"><span class="tit"><a href="https://blog.csdn.net/weixin_41830501" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}" target="_blank">耳东的慢生活</a></span>
                                            </div>
                    <div class="text"><span>发布了42 篇原创文章</span> · <span>获赞 7</span> · <span>访问量 5万+</span></div>
                </div>
                                <div class="right-message">
                                            <a href="https://im.csdn.net/im/main.html?userName=weixin_41830501" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-letter">私信
                        </a>
                                                            <a class="btn btn-sm  bt-button personal-watch" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}">关注</a>
                                    </div>
                            </div>
                    </div>
    </article>
    
Released five original articles · won praise 0 · Views 253

1. Add a plug-in pom service


                        <plugin>
     <groupId>com.spotify</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <version>0.4.13</version>
    <configuration>
        <imageName>eureka</imageName>
        <dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
        <dockerHost>http://Docker宿主机ip:2375</dockerHost>
        <resources>
            <resource>
                <targetPath>/</targetPath>
                <directory>${project.build.directory}</directory>
                <include>${project.build.finalName}.jar</include>
            </resource>
        </resources>
    </configuration>

</plugin>

2. Add the src / main / docker source folder, and add Dockerfile, content:

FROM java:8


VOLUME /temp


ADD eureka-service-1.0.jar app.jar
RUN bash -c 'touch /app.jar'


EXPOSE 8088


ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]


3. used locally: mvn clean package docker: build -DskipTests

If you're lucky enough, you can build on top of three steps should be mirrored on the server locally. I said the following about a variety of pit encountered! ! !

1) Failed to execute goal com.spotify: docker-maven-plugin: 0.4.13: build (default-cli) on project springb: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded .javax.ws.rs.ProcessingException: org.apache.http.conn.HttpHostConnectException: Connect to localhost: 2375 [localhost / 127.0.0.1, localhost / 0: 0: 0: 0: 0: 0: 0: 1] failed : Connection refused: connect ==== "this problem can be configured in the pom <dockerHost> http: // Docker host ip: 2375 </ dockerHost> to solve, but doing so may quote the following fault, I That's it

2) Failed to execute goal com.spotify:docker-maven-plugin:0.4.13:build (default-cli) on project eureka-service: Exception caught: Timeout: GET http://10.61.213.105:2372135/version: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: org.apache.http.conn.ConnectTimeoutException: Connect to 10.61.213.105:2375 [/10.61.213.105] failed: connect timed out

Here is the solution ==================== ========================== ===========

/usr/lib/systemd/system/docker.service add attributes:

The ExecStart = / usr / bin / dockerd -current into ExecStart = / usr / bin / dockerd -H tcp: //0.0.0.0: 2375 -H unix: //var/run/docker.sock, the original \ to retention and systemctl daemon-reload. Restart docker, telnet success (believe me there are a lot of pit), the effect is as follows:! [Here insert a picture description] (https://img-blog.csdnimg.cn/20200219224008611.png?x-oss-process=image / watermark, type_ZmFuZ3poZW5naGVpdGk, shadow_10, text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl8zMjgyMjc1OQ ==, size_16, color_FFFFFF, t_70)

3) If the above problem persists, there is no need to check the server port to open remote connections, the firewall may need to do some operations that can find some information on the Internet, and finally Good luck, do not use this kind can jenkins way up. . .




)in case

                        <li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#csdnc-thumbsup"></use>
                        </svg><span class="name">点赞</span>
                        <span class="count"></span>
                        </a></li>
                        <li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{&quot;mod&quot;:&quot;popu_824&quot;}"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#icon-csdnc-Collection-G"></use>
                        </svg><span class="name">收藏</span></a></li>
                        <li class="tool-item tool-active is-share"><a href="javascript:;"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#icon-csdnc-fenxiang"></use>
                        </svg>分享</a></li>
                        <!--打赏开始-->
                                                <!--打赏结束-->
                                                <li class="tool-item tool-more">
                            <a>
                            <svg t="1575545411852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg>
                            </a>
                            <ul class="more-box">
                                <li class="item"><a class="article-report">文章举报</a></li>
                            </ul>
                        </li>
                                            </ul>
                </div>
                            </div>
            <div class="person-messagebox">
                <div class="left-message"><a href="https://blog.csdn.net/weixin_41830501">
                    <img src="https://profile.csdnimg.cn/8/E/E/3_weixin_41830501" class="avatar_pic" username="weixin_41830501">
                                            <img src="https://g.csdnimg.cn/static/user-reg-year/1x/2.png" class="user-years">
                                    </a></div>
                <div class="middle-message">
                                        <div class="title"><span class="tit"><a href="https://blog.csdn.net/weixin_41830501" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}" target="_blank">耳东的慢生活</a></span>
                                            </div>
                    <div class="text"><span>发布了42 篇原创文章</span> · <span>获赞 7</span> · <span>访问量 5万+</span></div>
                </div>
                                <div class="right-message">
                                            <a href="https://im.csdn.net/im/main.html?userName=weixin_41830501" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-letter">私信
                        </a>
                                                            <a class="btn btn-sm  bt-button personal-watch" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}">关注</a>
                                    </div>
                            </div>
                    </div>
    </article>
    

Guess you like

Origin blog.csdn.net/weixin_32822759/article/details/104402311