为什么使用码头? Java文件是否已经在JVM上运行的WAR文件? [英] Why use docker? Aren't java files like WAR files already running on JVM?

查看:133
本文介绍了为什么使用码头? Java文件是否已经在JVM上运行的WAR文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用Java,并且开始掌握了Maven和Gradle的构建过程和依赖关系管理系统。



从我的理解中,Docker是在Docker主机中部署容器的好工具。我想像这样,Vagrant(虽然不是功能上相同)的方式是有用的,因为它消除了环境问题,而不是预期的。



我的理解是,当使用Maven或Gradle构建东西时,您可以创建一个包含其中的二进制文件的JAR文件或WAR文件,以便它可以在JVM的任何位置运行。使用Docker,这似乎是多余的。我想像Docker可以用于其他的东西,比如从C ++或其他任何东西运行的程序? Docker是否冗余Java使用?

解决方案

Java的可移植性主要是营销hogwash。




  • Java程序可以像其他任何东西一样进行系统调用(如文件系统访问或分支子进程),因此JVM不会隔离太多的东西,除非您正在使用安全管理器做奇怪的事情。


  • 没有一个JVM,而是每几年不同的一系列不兼容的JVM版本。还有竞争的实现,有时候是否使用Oracle的JVM或OpenJDK。




Docker也是关于隔离和再现性。例如,JVM没有类似于UnionFS。


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?

解决方案

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.

这篇关于为什么使用码头? Java文件是否已经在JVM上运行的WAR文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆