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.

  • Upload local files to docker container
  • How to automatically remove container data from the host when rm the container?
  • Proper Docker Setup for Multiple Websites
  • Linking Django and Postgresql with Docker
  • expose files from docker container to host
  • Error starting userland proxy: listen tcp0.0.0.0:3306: bind: address already in use
  • 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?

  • Docker container restart without data loss
  • Is it possible to use Docker Toolbox on Visual Studio Code?
  • Elastic Beanstalk Docker with Amazon CloudWatch
  • How do I properly use Silex 2, Doctrine, and PDO via docker containers?
  • Docker with Angular 2: cannot get
  • Auto-restart Docker container when contents of host folder change
  • 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 !!

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.