idea maven 打包推送docker以及私库

内容分享2周前发布
0 0 0

maven配置

  <docker.host>http://你自己的ip:2375</docker.host>
        <docker.version>1.2.2</docker.version>

<plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>${docker.version}</version>
                <executions>
                    <!--执行 mvn package 时 自动 执行 mvn docker:build-->
                    <execution>
                        <id>build-image</id>
                        <phase>package</phase>
                        <goals>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <imageName>localhost:5000/${artifactId}</imageName>
                    <imageTags>
                        <tag>${version}</tag> <!--指定镜像的版本标签-->
                    </imageTags>
                    <!-- 指定 Dockerfile 路径-->
                    <dockerDirectory>${project.basedir}</dockerDirectory>
                    <!--指定远程 docker api地址-->
                    <dockerHost>${docker.host}</dockerHost>
       <!--             <baseImage>java</baseImage>  &lt;!&ndash;基于java构建&ndash;&gt;
                    <entryPoint>["java","-jar","/${project.build.finalName}.jar"]</entryPoint>-->
                    <resources>
                        <resource>
                            <targetPath>/</targetPath>
                            <directory>${project.build.directory}</directory>
                            <include>${project.build.finalName}.jar</include>
                        </resource>
                    </resources>
                    <forceTags>true</forceTags>  <!--重复构建一样镜像则覆盖镜像-->
                </configuration>
            </plugin>

注意点:

  • imageName带localhost:5000/ 才会帮你推送到私库中,不然只是在docker里面生成镜像

  • execution 里面 把 docker build 集成到packge 里面

  • 最后执行 mvn clean package -DpushImage

远程docker服务器

  • 查看镜像库,发现已经对应版本的镜像了

    idea maven 打包推送docker以及私库

  • 查看私库

    idea maven 打包推送docker以及私库

番外篇 idea 安装docker插件

idea maven 打包推送docker以及私库

idea maven 打包推送docker以及私库

  • 看到connection successful 就能连上docker服务器了,我这边没有设置用户名密码,所以仅限私密使用,防止暴露
© 版权声明

相关文章

暂无评论

none
暂无评论...