maven - docker-maven-plugin 没有创建 dockerfile
问题描述
我正在使用 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 绑定到 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
推荐阅读
- python - 在 odoo12 社区中创建新的小部件
- html - 如何在 css-flex-float 中调整三个 div 一个左侧和另外两个右侧?
- python - Discord PY 如何获取所有服务器成员的列表?
- sql - 这个 Oracle 触发器有问题
- php - 如何从 Laravel 8 中的另一个控制器将参数传递给控制器中的函数
- python - Pygame中的箭头键移动
- azure - 将新函数应用添加到逻辑应用时找不到 Azure 404
- python - 如何保护用户的内部路由
- python - 终止在python中等待的线程
- mysql - 现有项目上的 Laravel Sail Mysql 8.0 问题