Docker - A Different Species Of Virtualization

In the early days, we used to have virtual machines (VMs). Virtual Machines helped us in managing different operating systems on the same hardware. It means on the same hardware, we can have Windows Server and Linux Server and so on. We also need to have Hyper-V to run this VMs.

Why Virtual machines?

  • Cost: Hardware is costly to buy for each service/component.
  • Wastage of H/W resources: If we keep the whole machine for a single application, then it will be a waste of resources if the compute power of server is not fully utilized.
  • Maintenance /Upgradation/Configuration of hardware.
So, due to these reasons, we have VMs. On the same hardware machine, we can have multiple operating systems using Hyper-V. Each OS shares the same hardware. Like main memory, host OS, etc.
Docker - A Different Species Of Virtualization
But here, the problem is we need to still maintain multiple operating systems with their configuration, licensing, security, etc.
The solution to all these problems is Docker & Container.

What is Container & Docker?

Container packages the application, libraries, and all its dependencies and deploys it to the server. Docker is a tool which helps us in making these containers. Now, the obvious question is what kind of application can we store in the container? Any application whether it's Windows or Linux or Mac-based, container shares the same operating system and hardware.

Structure of Container

Container contains a combination of multiple images. There is a stack of image layers. The base layer is framework related or OS related. Then, on top of that, we can have an application image layer. The top layer is the only layer which allows us to read/write and all other layers are readonly. The base layer we need to refer from the docker hub. More than million base images have been already created.
So lets take an example. If I have .net web API, then definitely, To run this API, we need core SDK runtime image and ASP.NET Core environment image and image of this API itself. So, my final image will have the API image, ASP.NET Core Image, and Core SDK runtime image. (Top to bottom in stack).
We will package this final image and build it. After building it, we can run it from any server (Windows/Linux/Mac).
N-tier architecture example: Front-end can run from one container. The database can run from another container. We can have multiple containers for the application layer.
Docker - A Different Species Of Virtualization

Benefits of having Containers

  • Scale up / down quickly: We just need an image of application. We can deploy/run multiple instances of this image from multiple containers.
  • Share same OS: No need to worry about OS. All dependencies of OS are already built in the image. No need to maintain multiple OS.
  • Open source technology.
  • Best for Microservice architecture.
  • Portable
Happy containerization!