Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

After upgrading my spring-boot application from spring-boot version 2.3.9 to 2.5.12 We have started getting below exception. Not sure if there is change related to docker in spring boot version 2.5.12

With previous version it was working fine but after changing gradle to 6.8 and spring-boot version this issue started ... any workaround to fix this issue? This is the command that causes error in 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 /

like image 622
Prashant kamble Avatar asked Jan 19 '26 17:01

Prashant kamble


1 Answers

There are now two jars in build/libs that match z-api-*.jar. This is due to Spring Boot 2.5 no longer disabling the jar task by default. From the 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.

You could update your COPY command so that it doesn’t match the -plain.jar that’s now produced by the jar task. Alternatively, you could disable the jar task:

jar {
    enabled = false
}
like image 80
Andy Wilkinson Avatar answered Jan 22 '26 14:01

Andy Wilkinson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!