Spring 引导版本 2.5.5 无法为复制命令创建 docker 映像

Spring boot version 2.5.5 unable to create docker image for copy command

将我的 spring-boot 应用程序从 spring-boot 版本 2.3.9 升级到 2.5.12 后 我们已经开始低于异常。不确定 spring 引导版本 2.5.12

中是否有与 docker 相关的更改

在以前的版本中它工作正常,但在将 gradle 更改为 6.8 和 spring-boot 版本后,这个问题开始了……有解决这个问题的解决方法吗? 这是导致 Dockerfile

错误的命令
ENV APP_HOME=/app/z-api/

COPY --from=build "${APP_HOME}build/libs/z-api-*.jar" app.jar

COPY --from=build "${APP_HOME}build/libs/z-api-*.jar" app.jar When using COPY with more than one source file, the destination must be a directory and end with a /

build/libs 中现在有两个与 z-api-*.jar 匹配的 jar。这是因为 Spring Boot 2.5 默认不再禁用 jar 任务。来自 release notes:

The Spring Boot Gradle Plugin no longer automatically disables the standard Gradle jar and war tasks. Instead we now apply a classifier to those tasks.

If you prefer to disable those tasks, the reference documentation includes updated examples.

您可以更新 COPY 命令,使其与 jar 任务现在生成的 -plain.jar 不匹配。或者,您可以禁用 jar 任务:

jar {
    enabled = false
}