6

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?

Chris Martin
  • 30,334
  • 10
  • 78
  • 137
Alexander Kleinhans
  • 5,950
  • 10
  • 55
  • 111
  • Wikipedia does a good job of explaining it, https://en.m.wikipedia.org/wiki/Docker_(software). It abstracts away from the app where it runs to provide for portability. It also provides for isolation between different apps. – Ola Ekdahl Dec 28 '15 at 02:55
  • There's more to a server than just the Java code. Docker does to the OS what the .jar does to java classes. – Adam Dec 28 '15 at 02:58

3 Answers3

7

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
2

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 !!

Community
  • 1
  • 1
Sabir Khan
  • 9,826
  • 7
  • 45
  • 98
2

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.

Chris Martin
  • 30,334
  • 10
  • 78
  • 137