In this tutorial we will discuss about high level overview on what is docker, why do we need docker and how it will help for you.
What is Docker?
Docker is a platform for developers and sysadmins to develop, deploy, and run applications with containers. This is often described as containerization.
In simple words, Docker is a containerization platform that packages your application and all its dependencies together in the form of Containers to ensure that your application works seamlessly in any environment.
More than that, Docker is a popular tool to make it easier to build, deploy and run applications using containers. Containers allow us to package all the things that our application needs like such as libraries and other dependencies and ship it all as a single package. In this way, our application can be run on any machine and have the same behavior.
For example, lets us consider a Linux based application which has been written both in Ruby and Python. This application requires a specific version of Linux, Ruby and Python.
In order to avoid any version conflicts on user’s end, a Linux docker container can be created with the required versions of Ruby and Python installed along with the application. Now the end users can use the application easily by running this container without worrying about the dependencies or any version conflicts.
Docker was first released in March 2013, only 5 years ago, but it is already used by a lot of companies, like: Spotify, The New York Times, PayPal, Uber and more.
What is Container?
Before discuss on what is container, lets discuss about virtualization.
Virtualization is the technique of importing a Guest operating system on top of a Host operating system. This technique was a revelation at the beginning because it allowed developers to run multiple operating systems in different virtual machines all running on the same host. This eliminated the need for extra hardware resource. The advantages of Virtual Machines or Virtualization are
- Multiple operating systems can run on the same machine
- Maintenance and Recovery were easy in case of failure conditions
- Total cost of ownership was also less due to the reduced need for infrastructure
As showing in the above diagram, you can see there is a host operating system on which there are 3 guest operating systems running which is nothing but the virtual machines.
Virtualization also has some draw backs. Running multiple Virtual Machines in the same host operating system leads to performance degradation. This is because of the guest OS running on top of the host OS, which will have its own kernel and set of libraries and dependencies. This takes up a large chunk of system resources, i.e., hard disk, processor and especially RAM.
Another problem with Virtual Machines which uses virtualization is that it takes almost a minute to boot-up. This is very critical in case of real-time applications.
Following are the disadvantages of Virtualization
- Hypervisors are not as efficient as the host operating system
- Running multiple Virtual Machines leads to unstable performance
- Boot up process is long and takes time
These drawbacks led to the emergence of a new technique called Containerization. Now we will discuss about Containerization.
What is Containerization?
Containerization is the technique of bringing virtualization to the operating system level. While Virtualization brings abstraction to the hardware, Containerization brings abstraction to the operating system.
Please note that Containerization is also a type of Virtualization.
Containerization is however more efficient because there is no guest OS here and utilizes a host’s operating system, share relevant libraries & resources as and when needed unlike virtual machines.
Application specific binaries and libraries of containers run on the host kernel, which makes processing and execution very fast. Even booting-up a container takes only a fraction of a second. Because all the containers share, host operating system and holds only the application related binaries & libraries. They are lightweight and faster than Virtual Machines.
As shown in the above diagram, you can see that there is a operating system (or host operating system) which is shared by all the containers. Containers only contain application specific libraries which are separate for each container and they are faster and do not waste any resources.
All these containers are handled by the containerization layer which is not native to the host operating system. Hence a software is needed, which can enable you to create & run containers on your host operating system.
Advantages of Containerization
- Containers on the same OS kernel are lighter and smaller
- Better resource utilization compared to Virtual Machine’s (VM’s)
- Boot-up process is short and takes few seconds
Now coming to what is containers. Containers are a method of operating system virtualization that allows you to run an application and its dependencies in resource-isolated processes.
These allow you to easily package an application’s code, configurations, and dependencies into easy to use building blocks that deliver environmental consistency, operational efficiency, developer productivity, and version control.
Containers can help ensure that applications deploy quickly, reliably, and consistently regardless of deployment environment.
Docker Container vs Docker Image
An image is a package or a template just like a VM template that you might you work virtualization world. It is used to create one or more containers.
Containers are running instances of images that are isolated and have their own environments and set of processes.