Don’t build fat jars for Docker applications

Jan Weinschenker
Mar 27, 2019 · 4 min read
Image for post
Image for post

Inefficiency and heavy load

A clever classpath to the rescue

$ java -jar application.jar
$ java -jar application.jar -cp \
lib/dependency1.jar;lib/dependency2.jar
$ mvn clean package
Image for post
Image for post
The contents of our target directory
$ cd target
$ java -jar application.jar

Dockerize it

COPY target/dependency-jars /run/dependency-jars
[INFO] — -> Using cache
[INFO] — -> 964d6819c057
[INFO] Step 20/24 : COPY target/dependency-jars /run/dependency-jars

Conclusion

Holisticon Consultants

voices of holistikoenner/innen

Jan Weinschenker

Written by

IT-Consultant, Developer, Nerd. Speaks Java and Kotlin. From Hamburg, Germany.

Holisticon Consultants

Promise! We listen attentively. We understand. And we do what we’re best at: honest technological and methodical management and IT consulting. Every day. With passion and talent. And the best people that we can find.

Jan Weinschenker

Written by

IT-Consultant, Developer, Nerd. Speaks Java and Kotlin. From Hamburg, Germany.

Holisticon Consultants

Promise! We listen attentively. We understand. And we do what we’re best at: honest technological and methodical management and IT consulting. Every day. With passion and talent. And the best people that we can find.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store