Learning Docker ๐Ÿ‹ as Newbie: Part 1

Photo by Ian Taylor on Unsplash

Learning Docker ๐Ÿ‹ as Newbie: Part 1

ยท

4 min read

Why Learn Docker ๐Ÿ‹ ๐Ÿค”?

Let's talk about Docker, What is Docker? What Problem does it solve? Why Do we need to learn Docker? What is the importance of Docker in the field of DevOps?
I hope most of you get these questions in your mind. You know what, it's good to get these questions as it will help us to see the purpose of Docker, in fact whenever we are trying to learn any concept we must know its purpose behind it and what problem it solves. With that note, I did start my DevOps Journey as I was convinced by the fact of it solving real-world problems on large scale and the responsibility of this role. In this blog, I will be sharing how I learnt Docker as a newbie.

The Problem

Before knowing about Docker let's start with Why do we need it?
So, as we know earlier the companies used Virtual Machines to host their application. Virtual Machines are actually Hardware Virtualisation, now let's say a VirtualBox has Two Virtual Machines with 4 VCPUs and 10 GB Storage, but our applications may not be that large, now imagine you have a small application which requires less than 0.1 VCPU and 100 bytes of RAM needed to run it but you are using so many resources (actually wasting the resources ๐Ÿ™) of the underlying machine.
Let's dig more by looking at the gravity of the problem. Our problem is that we are wasting a lot of resources on hosting a single application, now what if we were able to run our application with minimal usage of our resources? Sounds Cool, but how are we going to achieve it? We can see that the virtual machine space is occupied by OS, RAM, storage and the Library, Frameworks to run an application along with our small app. Now if we remove the OS and get to run our application by using the underlying OS of the hardware then one of our problems will be solved, i.e Space.
But there comes another problem which we haven't talked about i.e, in modern life companies or organisations use MicroService Based Applications which brings new problems like Conflicting Dependencies, as we know that in modern applications with Microservice Architecture, each with their dependencies, may conflict with those of other services. For example - in one service you want to run Node version - 12.1.1 but in another service, you want to run Node version - 16.4.3, this is called Matrix of hell. Also, Virtual Machines have a longer boot time.

The Solution

Above we discussed a few problems using Virtual Machines to host our applications. We also know that:

Where there is a will there is a way!

Let's see how Docker Solves the above-discussed problems:

  • Docker uses OS/Kernel Virtualisation, which solves the above problem of space. In short no OS inside the container
  • Docker uses namespaces and cgroup which makes an isolated environment for the containers using the Host OS. (It uses underlying OS)
  • Docker has Dynamic Resource Allocation which helps in minimal use of Resources
  • Docker is highly Scalable.
  • Docker eliminates the matrix of hell by keeping the dependencies contained inside the containers.
  • Docker takes very less time to Initialize an app.

    Imagine being able to package the application along with all the dependencies easily and then run the same across the development, test and production environments. Sounds so cool ๐Ÿคฉ.

What is Docker?

I hope by going through the above statements it is clear on Why do we need Docker and Which problem it solves.

Docker is a Virtualisation Technology that makes it easy to:

  • Develop
  • Deploy
  • Manage Applications

    Docker achieves all these by using containers.

What is Container?

If we want to build the application in Docker then we need containers. Docker is based on Linux Containerisation Technology. In simple words it uses two things to build a container:

  • namespaces
  • cgroups
    It can be considered a small VM with:

  • It's own Process

  • It's own Networking
  • Running Applications as root
  • It doesn't need PID1
    I have mentioned before that it uses OS Virtualisation which means I will be able to see the processes inside containers in the HOST Machine, but that's not the case in VM.
    In short, Containers are nothing but a Process.

What's Next ๐Ÿค”?

In the next Part, I will be deep diving into Docker Images, Containers, Volumes and Networks. I will be mentioning all the important commands used in Docker which anyone can use as a cheat sheet. Till then, I would highly recommend going through the official documentation of Docker.

Did you find this article valuable?

Support Arnab Maity by becoming a sponsor. Any amount is appreciated!

ย