简体   繁体   中英

Is it necessary to use Docker in Java?

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:

  • JVM just like a VM, which separate application from OS
  • Maven, manage dependencies
  • Spring Boot, support embed J2EE servelet containers like tomcat, all applications can be output as standard JAR file.

So, except you need to install JDK yourself, everything else is consistent and organized. I compare Java and Docker like below:

  • JAR -> Image
  • JVM -> VM

So, Docker really mean something for Java?

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM