Special Offer - Enroll Now and Get 2 Course at ₹25000/- Only Explore Now!

All Courses
What is Docker Container?

What is Docker Container?

May 14th, 2019

What is Docker?

To answer this question, let’s look at a problem that any software application developer faces. They develop a certain functional application in a certain environment and the minute they send it out for testing or production where the environments change, they start receiving flags about the application’s misbehaviour.
Now, the developer has to go back to the application and the environment in which it didn’t work perfectly on a case to case basis and solve for each of the problems. This is a cumbersome exercise because say the application is built in the Microsoft Windows environment and uses the services of MS Word. Now, if the application is run in a Linux environment, an MS Word substitute is to be cited, else the application would cease to function.

Any application has the following building bricks

  • Front-end components
  • Backend workers
  • Database
  • Environment libraries or dependencies and other stuff

So, to ensure that all the above-mentioned blocks are functional in all the possible environments is the way to build a fully functional application. And this makes the developer’s job cumbersome and tricky.
This problem is solved by the way of Dockers. Simply put, Docker is the world’s leading software container platform. Now, let us understand what a container is?

What is a Container?

Let us understand this through an analogy. Imagine there are different manufacturers across the world who produce goods of various shapes and sizes. Now, these goods are to be transported to all corners of the world. Now, since the products are of varied sizes, some of them can be transported on a van (say watches, clothes, etc.) while bigger products (like cots, cars, etc.) need bigger vehicles like trucks or ships to carry.
Now, to solve this problem, the logistics companies have come up with an idea. They have standardised the size of the container that carries anything. By standardising the size, the manufacturers are made to ensure that their products are packed (if much larger, dismantle and pack) such that they are fit into the container. Now, the logistics company would choose to ship the container however deemed appropriate (say, by air or water or land).
A software container is similar to that. Once the developer is done building the application, he/she would add all the details of the application (along with the building bricks mentioned above) and the dependencies attached into a ‘container’. Now, when a container engine installed in a certain OS runs this container, the application would smoothly run without any additional effort from the application developers to customise or solve for problems on each of these OSs or environments.
Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package. Docker is one such software container platform.

What’s Docker made up of?

A developer who’s working on a docker would have the following in place –

Docker file:

This is a text file that contains all the commands that can be used to assemble an image.

Docker image:

All the details of the application along with the libraries needed and other dependencies goes into this. Imagine it as a recipe of ingredients for a certain dish (application).

Docker Containers:

These are runtime instances of docker images that can be run in any given environment. So, when you want to run an application through the dockers, you instantiate the image in the environment.

Docker Hub:

The Docker Images can be stored on an online cloud repository called Docker hub. Now, the docker image can be called on to any environment from the docker hub and can be run.

Container Engine:

The engine that is installed over the OS which can initialise and run applications in parallel without affecting the performances of each other.

The Virtualisation Problem and the Docker Solution

When we choose to run multiple applications on a single system, we encounter certain problems :

  • The split of resources might be not even and might be potentially skewed towards a few applications handicapping the rest.
  • When the apps function in the same system, they are prone to potential threats from other applications affecting the performance.

The initial solution was Virtualisation through Virtual Machines. This is what they do. They divide the operating power of the host OS into smaller systems which would function with their own OS independent to the other OS environments. Now each of these OS would host one app each.
A certain software installed over the OS, called the Hypervisor, manages the sharing of the available physical resources across the VMs available and controls the space and memory allocated across.
The usage of virtual machines has come up with its own set of problems :

  • There was a wastage of processing power and memory as a few applications might have been needing greater amounts of power when compared to others and the system is static to such needs.
  • As each of the host OS is further loaded with virtual systems, the entire system becomes heavy making it unstable and also slow towards any changes.

Docker containers are a perfect fit for this. Applications can be run by initialising the docker images through the container engine that is installed over the host OS. This process does not need the OS to be split into parts. So, all the applications would use the processing power and the memory directly from the host OS enabling better flexibility in using the necessary machine power.
Since the docker containers are just simple files clubbed together, the entire system is extremely light making the actions faster and more agile.

Advantages of Docker Container

A quick summary of the advantages of using docker:

  • The App is to be built only once. An application inside a docker can run on any system that has Docker installed. So, there is no need to build and configure app multiple times on different platforms.
  • Testing has been made easy. With Docker, you test the application inside the container and ship it inside a container. So, the testing environment is similar to the production environment.
  • Portability is smooth. Docker containers can run on any platforms and a container running on, say AWS, can easily be ported to VirtualBox.
  • Version Control is available. Docker containers, like git repositories, allows you to commit changes to your docker images and version control them.
  • Apps are isolated. Every app has its own container and does not interfere with the other applications running on the system.
  • Productivity improves. Docker allows faster and more efficient deployments without worrying about running the app on different platforms.

Related Blogs