Docker / CoreOS上的Java JVM [英] Java JVM on Docker/CoreOS

查看:137
本文介绍了Docker / CoreOS上的Java JVM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



使用Java基础架构,是否可以在其中使用JVM自己的容器和其他Java应用程序/服务使用这个JVM容器?如果没有,我假设JVM必须在每个容器中绑定,所以本质上你必须拉Java中的Docker文件并合并我的Java服务;基本上创建了运行在CoreOS机器上的Linux Machine + Java + Service容器。



唯一的其他想法是可能在CoreOS本身上运行JVM,但似乎这是不可能的。

解决方案

实际上可以在 / opt 中解开Orcale Java,但这只是一种最后的手段JRE和JDK的Oracle二进制文件不需要任何系统库,所以在任何地方都很容易。



我写了一些很小的 JRE JDK 图像,我可以运行 Elasticsearch 和其他主要的开源应用程序。我还写了一些容器,让我在CoreOS上编译罐子( errordeveloper / mvn errordeveloper / sbt & errordeveloper / lein )。



正如@ISanych所指出的那样,运行多个Java容器不会影响磁盘使用情况,它几乎相当于在主机上运行多个JVM。如果发现运行多个JVM不是你的cuppa茶,那么答案确实是JVM不会像以前容器那样复杂。但是,容器中的Java还是相当不错的,因为你可以有一个永远固定的类路径,你不会陷入依赖的地狱。也许不是建立uberjars(这是我主要做的,尽管他们知道是不完全完美,但我懒惰),可以用tarball打包jars,然后在他们的Dockerfile中使用 ADD jars.tar / app / lib /


I'm learning CoreOS/Docker and am trying to wrap my mind around a few things.

With Java infrastructure, is it possible to use the JVM in it's own container and have other Java apps/services use this JVM container? If not, I'm assuming the JVM would have to be bundled in each container, so essentially you have to pull the Java dockerfile and merge my Java services; essentially creating a Linux Machine + Java + Service container running on top of the CoreOS machine.

The only other thought I had was it might be possible to run the JVM on CoreOS itself, but it seems like this isn't possible.

解决方案

It is actually possible to just untar Orcale Java in /opt, but that's just a kind of last resort. The Oracle binaries of JRE and JDK don't require any system libraries, so it's pretty easy anywhere.

I have written some pretty small JRE and JDK images, with which I was able to run Elasticsearch and other major open-source applications. I also wrote some containers that allow me to compile jars on CoreOS (errordeveloper/mvn, errordeveloper/sbt & errordeveloper/lein).

As @ISanych pointed out, running multiple Java containers will not impact disk usage, it's pretty much equivalent to running multiple JVMs on the host. If you find that running multiple JVMs is not quite your cuppa tea, then the answer is really that JVM wouldn't have to be as complex as it is if containers existed before it. However, Java in container is still pretty good, as you can have one classpath that would be fixed forever and you won't get into dependency hell. Perhaps instead of building uberjars (which is what I mostly do, despite that they are known to be not exactly perfect, but I am lazy) one could instead bundle jars in tarball and then use ADD jars.tar /app/lib/ in their Dockerfile.

这篇关于Docker / CoreOS上的Java JVM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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