r/learnjava • u/CodeyGrammar • Dec 11 '22
Why containerize a Java program using Docker?
I'm learning Docker and the idea of having a container for a Java app seems redundant to me since the idea of a JVM should make the Java code run on any environment?
But maybe I'm missing something and see if others containerize their Java apps using Docker and why.
46
Upvotes
59
u/ohlaph Dec 12 '22
What if I use Java 19, Bob uses Java 17, you use Java 11 and the project uses Java 11? If I want to run your project, it might not work, so I have to go find Java 11 first. But with a container, it pulls the same Java version for everyone and solves that issue.