Why use docker? Aren't java files like WAR files already running on JVM?
I’m new to using java and have just started getting a grasp of the build process and dependency management system of Maven and Gradle.
From what I understand, Docker is a great tool for deploying containers inside of a docker host. I imagine this is useful in the same way Vagrant is (although not functionally the same) in that it removes the issue of the environment not being what was expected.
It was my understanding that when building things with Maven or Gradle that you could create a JAR file or a WAR file that included the binaries inside them so it could run wherever the JVM was. With Docker, this seems redundant. I imagine that Docker is could be used for other things like programs running from C++ or anything else? Is Docker redundant for Java usage?
3 Solutions collect form web for “Why use docker? Aren't java files like WAR files already running on JVM?”
Java’s “portability” is mostly marketing hogwash.
Java programs can make system calls (like filesystem access or forking subprocesses) just like anything else, so the JVM doesn’t isolate much of anything unless you’re doing fancy things with the security manager.
There isn’t a single “the JVM”, but rather a series of incompatible JVM releases every few years. There are also competing implementations, and occasionally it matters whether you’re using Oracle’s JVM or OpenJDK.
Docker also isn’t just about isolation and reproducability. For example, the JVM has nothing resembling UnionFS.
Docker is about isolation and reproducibility.
The last point allows to specify an execution environment, with the exact brand of JDK/JVM that you need, for you to run on a dev machine (with a VM) or in production.
Years laters, even if you can no longer download the precise update revision of the JDK you used when you initially deployed that project, you will still be able to reproduce that execution environment.
I am not a Docker user ( Just familiar with concept ) but as per my understanding, NO , Dockers are not redundant for Java usage i.e. wherever Maven or Gradle being used. Docker is doing one more level up in terms of packaging ( Compared to maven etc ) by using containers.
Jar / War with all its dependencies in itself a portable entity but it doesn’t take care of host environment configurations. This questions will clear things a bit , Using Docker in development for Java EE applications
Obviously, its more useful for non – byte code languages but that doesn’t means it to be redundant for Java.
Hope it helps !!