gpt4 book ai didi

maven - docker-maven-plugin 没有创建 dockerfile

转载 作者:行者123 更新时间:2023-12-02 19:24:23 29 4
gpt4 key购买 nike

我正在使用 docker-maven-plugin 为 Java 微服务创建 dockerfile 和 docker 镜像。当我运行命令 mvn package -DskipTest=true ,它不会创建 Dockerfile。

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

以下是 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] ------------------------------------------------------------------------

最佳答案

您可能需要运行“maven package docker:build”而不仅仅是“maven package”。为了将 docker build 绑定(bind)到 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

关于maven - docker-maven-plugin 没有创建 dockerfile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57399529/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com