Reputation: 419
As Docker is a very hot tech currently, but I just wonder if it is necessary for Java? I list my reasons below, and any feedback is welcomed:
So, except you need to install JDK yourself, everything else is consistent and organized. I compare Java and Docker like below:
So, Docker really mean something for Java?
Upvotes: 10
Views: 3398
Reputation: 5949
Docker is not necessary for Java. You can run a JVM on an operating system without worrying about Docker.
Docker is similar to a JVM in that they are both a level of virtualization, but it is probably not helpful to think of the virtualization provided by Docker as the same as the JVM. Docker is really a convenience tool for packaging together multiple applications/services into a container that is portable. It allows you to build the same virtual environment on multiple possibly different machines, or to destroy a virtual environment and restart it.
If you run a jar file with different versions of the JVM, you may get different results. For example, if the jar includes Java 8 functions but you try running on a Java 7 VM, you will encounter exceptions. The point of Docker is that you can control versions so this does not happen.
Upvotes: 6
Reputation: 13834
You do not have to use Docker in Java but not for the reasons you gave.
Docker is not similar to a JVM! Docker is about having an isolated easily deployable environment that is configurable from outside, that can be started, stopped, and cloned easily.
Docker is similar to other virtualization technologies such as VirtualBox or VMWare but definitely not the JVM.
You can use Docker to select your OS, firewall settings, version of JVM and even more. You can use Docker to deploy 1 version or 1000 versions of your software. You can use Docker to give a fully-working environment to a customer or colleague.
JVMs do not do that.
Oh and there are security implications too.
Upvotes: 2
Reputation: 3895
Depends. How much version support does your code has? How do you deploy your code? Do you use any databases and libraries other than java?
Docker is mostly for simplification of development process even when the one dev's machine differs from other. While java takes care of that by using jvm, think of a case when you are using functions that are on a newer java version, but your peer has an older java version on his machine. God forbid its your server.
Same applies when you are launching other services along with your java app. They will be databases and other services which will be versioned. Though internal libraries of java are themselves maintained by maven, they have no control over other services that you are dependent upon.
In short, no, Docker is not necessary for Java. Its not necessary for any language actually. It just creates consistency across multiple devs and production and other services, and hence the popularity.
Upvotes: 5