DEV Community

Cover image for Concept of Containers
Pratik Singh
Pratik Singh

Posted on

Concept of Containers

This article will cover the introduction, basics, and usage of Containers. This might not be very beginner-friendly. Let's get started!

"Containers are lightweight packages of your application code together with dependencies such as specific versions of programming language runtimes and libraries required to run your software services."

The source of this is Google Cloud, good resource to learn more on containers.

You can put in literally anything in a container

Relate to the concept of containers to be same as that of a real 🚢 container. From a toy car to a real car all are shipped overseas using containers. No matter the object or the size everything can be shipped in a container.
Whether you are making a Golang server or a Machine Learning model, you can ship it in a container.

Every container runs independently on your system. It runs its own OS, filesystem, network while sharing the OS kernel of the host's system.

  • Do I mean it's similar to a Virtual Machine?

No. There is a big difference in a VM and a container. VM's are heavy independent software that runs on your system. While containers share resources not only with host but other containers as well (if needed). More over Here

Many assume that the concept of Containers is pretty new and was developed a decade ago or so. But this is not the case, the concept of containers was introduced back in 2008. Over the time it evolved and recently became popular when the micro-services architecture took off.
Even if you are not familiar with containers, you would have atlast heard of Docker! (Kudos to the marketing team xD )

  • Is Docker the sole Containerisation platform? No there are several other options like Podman, OpenVz ad others. Docker is popular because of its simplicity and power it brings to you. If you want to learn docker instead, Here

Let's talk more on Containers, bear with me for a while.

When I give two people the lyrics to a song. Both of them will sing the same song, but will sound different, right?
Suppose we created an mp3 file 🎶 of the song and then send it to these folks. There won't be any difference in how it plays and sounds.

That is the concept behind Docker in simple words.

There are multiple components of a Container in the real life implementations.
First comes is the architecture of a container while running:

  • Docker Image : This is like a compressed file that stores all the binaries and code of your application with the Os and environment you need to run it on.

  • Container runtime : This component is an important one. It is responsible to start and run a container. runC is one of the most popularly adapted one.

  • Container Engine : Again there are multiple engines out there and Docker dominates it too. An engine as it sounds is important and sits on top of everything. It manages the containers, the network, I/O streams, CLI commands and more.

There are some other components as well, but it will exceed the scope of conversation this article.

When we are discussing containers I have to bring up OCI. As the conversation might not be complete without it.

OCI (Open-Containers Initiative):

So, when containers had started to convert over monolith system to microservices. There was a lot of confusions as what standards to follow while containerising the new services. People had bash or pearl scripts all over the place to keep the pieces work together. It created open industry standards around container formats and runtimes.
Read more: Here

There are obviously a few things that I to skip because they would have just extended the article as well. Also I am still a beginner, I will keep on adding stuff as I learn :)

I share a few interesting articles around the topics. Hope it helps you and would urge you share a few more in the comments that I can learn from.

Thanks for reading my article :)

P.S.: All these great images are built using DALL-E

Top comments (0)