docker-maven-plugin没有创建dockerfile

bogh5gae  于 2023-10-17  发布在  Maven
关注(0)|答案(3)|浏览(133)

我正在使用docker-maven-plugin为Java微服务创建dockerfile和docker镜像。当我运行mvn package -DskipTest=true命令时,它不会创建Dockerfile。
我正在使用docker-maven-plugin为Java微服务创建dockerfile和docker镜像。当我运行mvn package -DskipTest=true命令时。它成功运行,没有任何错误,但它不会生成Dockerfile。查看屏幕上发出的消息,尽管在“build”中配置了该插件,但它看起来并没有运行
下面是pom.xml中构建任务的配置:

<build>
                <plugins>
                        <plugin>
                                <groupId>org.springframework.boot</groupId>
                                <artifactId>spring-boot-maven-plugin</artifactId>
                        </plugin>
            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>1.1.1</version>
                <configuration>
                    <imageName>explorecali-${ec-profile}</imageName>
                    <baseImage>java</baseImage>
                    <entryPoint>["java", "-Dspring.profiles.active=${ec-profile}", "-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>
                    <buildArgs>
                        <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
                    </buildArgs>
                </configuration>
            </plugin>

        </plugins>
        </build>

没有错误消息,但没有Dockefile。下面是我运行它时屏幕上发出的消息:

[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.example.ec:explorecali >---------------------
[INFO] Building explorecali 2.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ explorecali ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO] Copying 7 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ explorecali ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ explorecali ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\fikhas\dev\spring\Ex_Files_Ext_Docker_Spring_Boot\Exercise Files\Ch05\05_05\explorecali\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ explorecali ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ explorecali ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ explorecali ---
[INFO] Building jar: C:\Users\fikhas\dev\spring\Ex_Files_Ext_Docker_Spring_Boot\Exercise Files\Ch05\05_05\explorecali\target\explorecali-2.0.0-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.0.1.RELEASE:repackage (default) @ explorecali ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.576 s
[INFO] Finished at: 2019-08-07T13:25:58-04:00
[INFO] ------------------------------------------------------------------------
nszi6y05

nszi6y051#

您可能需要运行“maven package docker:build”而不仅仅是“maven package”。为了将docker构建绑定到maven阶段,你也可以尝试这样做:

<execution>
<id>build-image</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>

来自https://github.com/spotify/docker-maven-plugin#bind-docker-commands-to-maven-phases

lokaqttq

lokaqttq2#

将插件添加到插件

<plugin>
   <groupId>io.fabric8</groupId>
   <artifactId>docker-maven-plugin</artifactId>
</plugin>
83qze16e

83qze16e3#

您可能还需要使用dockerfile-maven-plugin,而不是docker-maven-plugin(当前未激活)

<artifactId>dockerfile-maven-plugin</artifactId>

相关问题