My question can be rephrased as: Pros and cons of docker or other container for Java application.
I found tons of information about Docker and VM, but I could not find an article about Java in Docker advantages.
A Java program is running as a JVM process, already a "so called" virtual machine. Why do many IT people want to run a Java program in docker?
There are tools to help manage docker containers: kubernetes, docker-compose, Docker Swarm, etc. It is easier to deploy the whole application (micro-services architecture, for example), with any custom config so easily: docker-compose up
and docker-compose.yml
defines the configuration. It is also easy to do orchestration and scaling with such tools.
Is it possible to manage JVM (Java Virtual Machines) in a similar way as we can manage containers? Is there such tool or technology out there? One hardcoded limited solution came to my mind is to make bash scripts to deploy all your application stack.
Before containers, we would run our applications in virtual machines in cloud. But a virtual machine is expensive (more resources are required to run your application, also there is a host OS, and VM OS). Docker technology allows to run your application process inside a container, using host OS ( assuming that container and host OS have the same kernel, for example both of them Linux based).
Another benefit of a container is ease for development. Instead of installing different dependencies for your application (databases, caches, application servers, proxy servers, etc), you can get images you need and run containers from them without installing these dependencies on your dev machine.
But again, why not run a JVM process on host machine for production? Example, we have five containers, and we know that they will be running a Java process there (it is important; otherwise it will make sense to use an individual container for each technology stack). So we can have one host machine with JRE installed, and we can run 5 JVM processes there without containers. Why not?