Open In App

Why do we need containers ? Need of containerization and the OCI.

Last Updated : 08 Jan, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Docker and containerization have been the base for modern-day applications and DevOps. But do you also wonder why containers exist? and why a product like Docker has been so successful. In this article, we are going to discuss the motivation behind a tool like Docker why the developers felt the need for containers, and the industry-accepted specifications of those containers. We try to understand why containers have become the dominant kind of development and deployment mechanism for software applications today.

What is a Container?

The Docker official docs say that a container image is a lightweight Standalone executable package of software that includes everything needed to run an application. You can think of a container as a box that contains the underlying OS dependencies.

container classification

For example, if I was writing an application code in Python it would have the Python runtime with the version that is needed, it would have all the Python libraries that I am using, it would also have the application code and all of this would be bundled into a single container image. Now we can use this container directly to execute our application in any Operating System or machine and we can also run multiple copies of it.

Architecture of Containers

The architecture of containers looks something like this –
architecture of containers

At the bottom we have either a virtual or physical Hardware with an operating system and then we have a layer of the container runtime that takes a container image and run it within the host system. Above these container runtimes, we have our containers.

Container image is this artifact that has all of the dependencies within it. Container is what you run from that image. So a container allows you to have the standardized packaging that you can then use to create one or more copies of the container and those copies are going to be the same every single time.

OCI (Open Container Initiative)

OCI or the Open Container Initiative was created because there were a few early players including Docker who built out the early implementations of containers but then more and more companies started building their own implementations of containers. As containers became more popular, companies realized that rather than having a whole bunch of slightly different but similar containers it would make much more sense to come together and create one standard that can be used across different implementations. This was how OCI or the Open Container Initiative was born.

Various Companies including Docker, Google, VMware, Microsoft, Dell, IBM, Oracle and many more came together and created open industry standards around what a container is? and how it should be run? The official docs of open container initiative says – The Open Container Initiative is an open governance structure for the express purpose of creating open industry standards around container formats and runtimes.

OCI or the Open Container Initiative has three specifications:

  1. The Image Specification
  2. The Runtime Specification
  3. The Distributions Specification
  • The image specification defines what should be included in the image in terms of metadata and the format.
  • The runtime specification defines how one would take an image that follows the image specification and run it in a container.
  • The distribution specification talks about how those images should be distributed by pushing and pulling images in Registries

And these three things together make up the open container initiative and Docker has a specific implementation of this standard.

Why do we need containers

There are many use cases of containers and many of them might depend on the need of your organization. But the three most important reasons why Containers came into existence and why they became a sort of industry standard are:

1. “But It works on my machine”

You must have seen this in form of meme or somebody saying this on internet – “But It works on my machine”. It is this idea that I’m building a software application I get it running locally but then something goes wrong in the process of translating that local system to the production one. This is the first reason why we needed Docker and why we needed containers in general, one thing that containers does really well is that it helps to make our local environment as close as possible to the production environment that we are going to deploy to. We can take the local environment and just ship it directly to production.

2. Making the Software Development Life cycle simpler

There are two main aspects of the software development life cycle that Docker and containers are trying to address – First one one is on the development side and the second one on the deployment side. Basically what used to happen before Containers didn’t exist was while building a software application in an organization is we install all the packages and tools that are required, run scripts and get everything configured in order to run the application locally and code in it. This process is very complex and it has a lot of chances of human error.

What Docker did was it simplified this process – Now setting up the development environment can be done by running a single command. You don’t have to manually install all the dependencies and track their versions, you just have to enter a Docker command and Docker with the help of container (since the application is containerized) does that automatically. Docker took the whole complex sequence of events that one needed to run and turned that into a singular system and command that everyone can run.

3. Making the Deployment simpler

Deployment is once you have build an application you will need to put it in some server in order to make it available to the world. In this deployment process, a number of steps used to happen. for example, we would create a server running Ubuntu then we would run some configuration software like ansible to get all the dependencies configured, and then finally we would copy our application code onto the server and run it with these configuration options. You can see this again comes with a lot of steps and a lot of complexity and much harder to ensure that it is going to be right every single time.

What containers do is they bring a single standardized package such that as long as the server has a container runtime, all you need to do is take this standard container image and run it with these specific options and your application is good to go. Because we containerized our application, we don’t have to worry about the underlying operating system and the underlying dependencies as long as we have our system and a container runtime and our container image, we can run it and get repeatably reliable results over and over.

Benefits of using containers

1. Containers are portable

One great advantage of containers over other form of deployment is that it is portable, Irrespective of your operating system, your computer’s specs or anything else, containers can run on any host. We would just need an appropriate container runtime, making it easier to deploy applications across different environments.

2. Bringing our local environment as close as possible to the production environment

Like we discussed earlier, one thing that containers does really well is that it helps to make our local environment as close as possible to the production environment that we are going to deploy to. We can take the local environment and just ship it directly to production.

3. No need to manually install all the dependencies

With containers, setting up the development environment can be done by running a single command. We don’t have to manually install all the dependencies and track their versions, we can simply enter a single command for installing all the dependencies required to run the application.

4. Containers are scalable

Containers are the new industry standard because they are scalable. Containers can be started and stopped in seconds, making it easy to scale applications up or down as needed.

5. Containerization enables Isolation

Containers provide strong isolation between applications, ensuring that they do not interfere with each other or with the host operating system. But why does it matter? Because installing dependencies in one application should not affect another. If there is an application using go v1.8 we would not want this version to be upgraded if we install go v2.0 in any other application, so we will simply containerize both of them.

Use cases of containers

There are many use cases of containers. And honestly it depends on the developers how they want to use containers for creating and deploying their application. We already have discussed the benefits of containers, so other then that following are the most important use cases of containers:

  1. Creating lightweight stateless applications.
  2. Using containers for continuous integrations.
  3. Using containers for Internet of things (IoT).
  4. Using containers for Big data.
  5. Building cloud native applications.
  6. Developer Productivity and Early Application Development.
  7. Using containers for faster application startup.
  8. Using containers for Faster deployment.

Conclusion

In summary, Developers are lazy, and also smart. Containers came into existence in order to make the process of software development and deployment simpler. Rather than manually installing multiple dependencies of just the exact version, now developers can install all the dependencies in just one command and that too of the required version. These containers brought our local environment close to the production environment and helped senior engineers give a savage reply when told by their juniors – “But It works on my machine”.

Frequently Asked Question (FAQs)

1. What purpose does containerization serve?

Through containerization, we can create applications that are portable, scalable, efficient and isolated with one another.

2. Which is the most commonly used tool for containerization?

Docker is the most common tool used for containerization

3. Which companies are using containers?

Spotify, Netflix, Uber, etc. all these companies are using containerized applications.

4. What are containerized applications?

Those applications that are running in containers are called containerized applications.

5. What is a container?

A container is a way to package an application along with its configurations and dependencies for simplifying the process of development and deployment.

6. Is Docker a container runtime?

No, Docker Engine is a container runtime. Docker is a tool to build, share, and run container applications.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads