What is Containerization?
Containerization has become a latest trend in software development as an alternative to virtualization. It packages the software code and all its dependencies as a single package called container so that it can run uniformly and consistently in all the environments.
In traditional software development, code developed in one environment might cause errors while running in other environments. This problem can be solved by using containers. In simple words, containerization allows applications to be “written once and run anywhere.”
How Containerization differs from Virtualization?
- In virtualization, a hypervisor runs on top of host OS, whereas in containerization, a containerization engine runs on top of host OS.
- Hypervisor runs a full-fledged OS on top of it, whereas containers runs on top of containerization engine.
- OS which is running on top of hypervisor has its own kernel, whereas the containers share the kernel with the host OS.
- Both containerization and virtualization use an image, but the image size of a container is much smaller when compared to that of the OS Image.
How Containers work?
Containerization involves packaging / building the application together with all the dependencies, configuration, files, libraries etc. which are required for an application to run.
Normally, if you have run an application in virtualization and you wanted to run a LAMP stack, you would install a LAMP stack and just run it as a service. This will bind the service to the desired ports of 80 and 443 and starts to run in background as a service. The configuration which is required for this service to run will be placed in a file system inside the OS. Now, if you want to run another LAMP stack, it’s not that easy as you did it for the first application. Even if you were able to run another LAMP Stack in the same server, managing those will be a hassle. You would have two LAMP stacks sharing the same root folders. If it lacks proper permission control, then the two stacks might interfere each other.
Containerization allows these two separate stacks to be isolated from each other. These two stacks can bind to the same ports, have their own root directory and they manage their own permissions. They seem to operate as if there is only one LAMP stack in their own OS. The isolation of applications as containers also reduces the chance that malicious code present in one container will impact other containers or invade the host system.
Containerization allows developers to create and deploy applications faster and more securely. Containers are often referred to as “lightweight,” meaning they share the machine’s operating system kernel and do not require the overhead of associating an operating system within each application. Containers are inherently smaller in capacity than a VM and require less start-up time, allowing far more containers to run on the same compute capacity as a single VM. This drives higher server efficiencies and, in turn, reduces server and licensing costs.
Benefits of Containers
- Lightweight: Compared to virtual machines (VMs), containers are significantly lighter on server resource usage. This is because unlike VMs, containers share the host operating system, and thus containers do not have operating systems of their own.
- Fast: Being lightweight and not having an operating system means that containers are able to start and stop much faster than traditional VMs.
- Secure: Containers are built on the concept of “namespaces”. Much like a traditional VMs, this essentially means that your apps are sandboxed, and not able to communicate with each other, (unless of course, you want them to!) This concept can be leveraged to help keep your apps secure and, data is only exposed between apps as you choose.
- Portable: Container engines such as Docker are highly portable and able to run on basically any system. This means your developers are free to write the application on any system they choose and then deploy it on Mac, Windows, or Linux once it’s ready.
- Easy to scale: You can keep your services highly available, and able to dynamically adjust to the flow of internet traffic by easily scaling up / down.
- Simple and Fast Deployment: Another main benefit of containerization is its ability to simplify and speed up the deployment and configuration processes. With containers like Docker, you can create a single “master” version of your image to quickly deploy on-demand.
“Cloud is about how you do computing, not where you do computing.”
~ Paul Maritz, CEO of VMware