Spread the loveNow a days, everybody is talking about containers but what that actually means ? what is a container
Now a days, everybody is talking about containers but what that actually means ? what is a container actually are ? these are the questions quite frequently coming into our mind. This post will discuss on the same topic and try to cover the basic idea behind this technology.
Let’s start from the previous architectures, in simple words, a software developer will develop the code for example a java based application, in that application development process developer declare and use various namespaces/packages in their java code files for example java.io for file input and output stream ( Reading and Writing ) from/to a file.
These namespaces actually are previously written code , provided by JDK to reduce the development time & efforts, so that developers need not to write repeatable code again and again they will simple call the namespace and use the methods or classes in that namespace. JRE ( Java Run-time Environment ) will provide actual implementation of those namespaces to the applications or java code at Runtime to successfully parse and execute that application code.
We need Java Runtime environment to deploy our application, in case of of java based application, JRE will be the provided by JVM Java Virtual Machines.
Here we understand that, we need jvm to run our java application as it provide runtime to our applications, it’s a mandatory thing for our applications.
With Traditional Approach:
These JVM has been provided by Java based application servers like : Jboss , Tomcat, WebSphere and Weblogic etc.
In Current Approach :
Let’s Assume we need to deploy same java application which we deployed in traditional approach on Weblogic, This time we need to deploy that application in container.
In this approach, first of all , we need to write a docker file ( set of instructions / commands ) in a text file, explaining our future containers layers, means what all we required inside our container which we are about to create, in other words docker file is the instructions which explains inside architecture of the container.
Content of that docker file generally start by a “From” command,
From BaseImage ( RHEL / CENTOS) etc : This means what will be the base image of your containers operating system when it will be running.
Then you will specify what all software will be required in that container and over that base OS which we layered via “from” statement in our docker file, for example to host a java application in a container we will required a java application server ( tomcat / jboss ), like we used them in traditional approach.
Now you may be thinking, we used same application server to host our applications in traditional approach, and we are using same application server in containerized approach so what’s the difference ?
Note: Previously, you are using VM or Physical servers to install full featured Operating system like RHEL, then we install java jdk and application server on that OS, then use to deploy our application over it.
Next we need to provide the path of our application code which will be deployed into that application server ( .jar, .war, etc.)
Note : In containers we will not use the same software we were using earlier, most of the major companies are providing their container friendly products like ( Jboss specifically tuned for containers ).
When we have our docker file ready, we will initiate it and create an object or snapshot via build commands, incase of docker it would be docker build.
Still we don’t have container, Instead we have container image, here again we required a runtime which will run our container image and create an actual container ( linux process ) from that image.
for this we will use docker, docker is actually providing runtime to host our containers on it.
There are different type of container images available in the market which required different runtimes to host those containers, docker is the most command container runtime available in the market but it’s not the only one, if a different format image we received then we do required a different container runtime which support that type of image.
Few things about command characteristics of a container
Containers are light weighted linux processes
Containers are actually isolated chunk of same host kernel.
Containers are ephemeral in nature and tend to die.
Containers need a guest OS (which runs inside them)
Containers are interoperable in nature they don’t have any external dependency and can be run at any platform with same results.
The main reason behind this approach is less resource consumption, no sense of huge sized containers, they should be light weighted.