欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

maven: build docker image

程序员文章站 2022-03-12 16:40:08
...

maven build docker image

  1. add docker maven to pom.xml
        <plugin>
            <groupId>com.spotify</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>0.4.13</version>
            <configuration>
                <imageName>${project.name}:${project.version}</imageName>
                <baseImage>java</baseImage>
                <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>
                <!--docker宿主机的ip,要为docker开通tcp访问才有效-->
                <!--<dockerHost>http://8.129.181.68:2375</dockerHost>-->
                <dockerHost>http://localhost:2375</dockerHost>
            </configuration>
        </plugin>
  1. exec cmd below
    sudo mvn clean install
    sudo mvn docker:build
相关标签: docker java maven