Introduction to Docker (PART 1-meant for Beginners)

This Tutorial is meant for Beginners. In part 1 of this Tutorial, I’ll be giving an introduction to Docker. So, there isn’t any prerequisite for this part of the tutorial. You can just have a computing background and you’ll be able to understand the importance of Docker and Containers in Docker.

This part of the tutorial will cover the following: –

  1. Why do we need Docker?
  2. What is Docker?
  3. Docker Architecture ( client-server architecture )?
  4. What is the Kernel of an OS ( Operating System)?
  5. Are Containers OS Specific?

1. Why do we need Docker?

If you have a computing background, you may have encountered a meme. “It works on my machine …”

Sometimes we spend months building an application, and after completion of the development process, it doesn’t work on a testing machine or shows some dependency issues during deployment. We as developers usually had the excuse “It Works on my machine.” Now, the question is, why a code may work on one machine during development and the same code not work on another machine during testing or deployment? There could be multiple reasons including the following issues.

(i) Dependency IssuesSometimes, libraries or software being used in a code have dependencies that might not have been installed on other testing machines, and can cause issues.

(ii) Software version may not match: Two applications on the same machine may need different versions of the same software. As an example, if we are using TensorFlow for building a deep neural network, and we have two different applications. They may need two different versions of it e.g. TensorFlow 1.2 and TensorFlow 2.0. So, if you already have installed one version of the software, other applications may have errors on this machine.

(iii) You may not have configured it: What if some new developer has joined your team, in that case, he/she will have to configure one’s machine to run an already built application. That may include installing all dependencies and necessary software.

So, these are a few of the many reasons why we needed a way to package the application with everything it needs to run. In that case, it can run on any machine, and we wanted to isolate one application from others. So, we can use different versions of the same software for different applications on the same Operating System. Make sense? Here is when Docker comes in …

2. What is Docker?

Docker is a set of products that deliver software in packages called Docker Containers and provides solutions to all of the mentioned problems in the previous section. It packages an application with all its dependencies and required software into a container, that helps us build, run, and ship applications very efficiently. All Docker Containers are an isolated environment managed by Docker Engine.

3. Docker Architecture ( client-server architecture )?

Docker works just like Client and Server Architecture. As Client communicates with Server using REST API. Here we call Server a Docker Engine.

(i) Docker Engine is an open-source containerization technology for building and containerizing your applications. It runs in the background and is responsible for building and running Containers.

(ii) Docker Container is just like any other process running on your Computer. These are lightweight special processes and don’t need a separate OS ( Operating System ) like Virtual Machines or dedicated slices of hardware including cores of CPU and some specific chunk of RAM etc. Containers on a host machine share the OS running on that machine. More specifically, they share the Kernel of the Operating System running on that host machine. Don’t know what kernel is? That’s fine, I got you covered.

4. What is the Kernel of an OS ( Operating System)?

The kernel is a portion of OS code that is always there in memory and facilitates interactions between hardware and software components. It manages all applications and hardware resources like CPU and Memory.

Here comes the problem! Every OS has its own Kernel and API for communication between the kernel and processes running on that computer. So, we can not run a windows application on Linux because that application will have to talk to the kernel of the OS in order to access hardware resources. And Linux doesn’t have a Windows kernel.

Remember, we said Containers are just like processes running on a Computer. That arise one more question, Can we run Containers of one OS on another OS? Let me answer in the next and the last part of today’s writing.

5. Are Containers OS ( Operating System ) Specific?

Yes, They are. Let me explain by talking about three Operating Systems, Linux, Windows, and MAC OS.

(i) Windows Containers: If we specifically talk about Windows 10, it has both Windows kernel and custom-built Linux Kernel as well. So, we can run both Linux and Windows Containers on it.

(ii) Linux Containers: Linux does not have Windows Kernel, that’s why it only supports Linux Containers.

(iii) MAC OS Containers: When it comes to MAC OS, it has its own kernel and doesn’t have native support for Containers of Applications. So, Docker on MAC OS needs to use lightweight Linux VM ( Virtual Machine ) for running Linux Containers on MAC OS.

Wonder, what’s the difference between using a Virtual Machine to have an isolated environment for an application and using Docker to create a Container for that application? I’ll have given a comparison of VM (Virtual Machine) and Docker Containers in the next part of this Tutorial. Here is a link to part 2 of this tutorial: