Docker- Why do we need you?
To get rid of pain across the cross-functional teams
If you are in the development world, you have heard about Docker. It is so much in trend that last time, one of my colleagues in management from non-CS backgrounds asked briefly about it.
When you are building a small application on your machine, there is no problem, but when the app grows, you need to scale it and work with other members across different levels, such as QA Teams, DevOps teams, Dev Team, etc. There you start getting version mismatch and software mismatch etc.
Docker is a software platform that allows you to build, test, and deploy applications quickly and takes care of your pain of deployments and version mismatch.
Your app is working on the dev side but not on the QA side due to software mismatch or any other issue on the QA side (It might be QA team has installed any other dependency).
The solution is to share Operating System, and the problem is solved.
App+ OS +Softwares
But it is not possible to share operating systems in practice.
Have you seen someone sharing their Linux kernel in real-time?
— Not a Realistic Solution.
— So, here comes the concept of Virtualization!
Virtualization is done on your infrastructure (laptop’s hardware)
Configuration of 32GB of RAM, 1 GB Hard drive, and Windows OS installed with 16 CORE CPU.
Now you installed hypervisor. Hypervisor helps in Virtualization. It creates VM(Virtual Machine).
You asked your hypervisor to create two Virtual Machines of 8GB RAM each.
So, 16 GB RAM is used.
On one OS, ubuntu is installed. On the second, Linux is installed. Remember they will be using laptop resources taking RAM and storage from the laptop’s hardware only.
So all the necessary software and application will be installed on those virtual machines, and the Image will be shared with the desired team (QA, Ops, etc.)
Now this problem is solved by Virtualization without any need or discussion of Docker.
You are saying Docker is not in the picture.
Now, consider this Scenario
You asked the hypervisor to create two more VMs of 8GB and 16 GB each.
— But wait, it is getting resources from your machine’s hardware. The first Scenario already allocated 16 GB.
Left with 16 GB on hardware —
Now third VM will get created successfully.
For 4th one, the hypervisor will not be able to create since there are not enough resources available to create it.
There might be a possibility that any VM in your setup is not using resources; that VM cannot release its resources to allow the hypervisor to create another VM.
Wastage of Resources is happening in Virtualization.
So, this problem is solved by the concept of containerization in Docker.
Point to be noted In Docker —
- Like hypervisor, here we have Docker Engine.
- And the virtual machine is replaced with a container here.
Docker container does not use a separate OS for its purpose, so resources are getting saved up.
We are saying here docker container does not use a seperate OS but we often see container having OS.
What does that mean?
It has small files of OS that it uses. Instead, it will get common files from the host(laptop) according to requirements and release it after completing the requirements.
In the above two Scenarios, you were allocating fixed resources that cannot be altered after creating the VM; here docker container will ask according to changing requirements and release the resources after using it.
Image: The image is like a template. A Docker image is an immutable (unchangeable) file that contains the source code, libraries, dependencies, tools, and other files needed for an application to run. You can say When the container is not in a running state.
Container: Container is the Running state of the image. It provides a runtime environment to the image. Docker packages software into standardized units called containers with everything the software needs to run, including libraries, system tools, code, and runtime.
Container resolves all the dependencies-related issues for the application. Container brings software from Docker Hub. Docker Hub is a service provided by Docker for finding and sharing container images with your team. In simple words, any software that an application requires is present in the docker hub as images.
Let’s see the ecosystem of docker and take overview of the some practicable terms in docker.
1] Docker Server- Also called Docker Daemon or Docker Engine.
- It helps us to make Images and convert our Images into container.
- It executes our commands. Docker Daemon runs on the host OS.
- is responsible for the running container to manage docker services.
- Docker Daemon can communicate with other docker daemons.
2] Docker Hub: All the images are stored inside the hub. Docker registry manages and stores the images. They have two registries-
Public registry — called docker hub.
Private registry for enterprises.
3] Docker Client: The client is where we are working and building our code. Docker users interact with the Docker daemon through the client.
When a client runs terminal command, it is sent to the docker daemon.
Suppose the user wants to create one container.
The user interacts with the client, and the client takes the user request to the daemon. And then, the daemon will create a container at the client’s request.
4] Docker Host is used to providing the environment to execute and run applications. It contains the docker daemon, images, containers, networks, and storage.
5] Images: It is a template having the necessary files.
6] Docker Compose: Help to run multiple docker containers.
Now Let’s come to it’s advantages and disadvantages quickly —
Few Advantages of Docker :
- Less Cost, since it is not asking for resources every time. Docker is light in weight also.
- It helps to build a container image and share and deploy that Image with other teams resolving version and dependencies-related issues.
- No Pre Allocation of resources is done.
- Less time is required to create a container.
- Images can be reused.
Disadvantages of Docker:
- Docker is not a good solution for application that requires a rich GUI. It is preferred for the application where the role of the command line is more. For making an app like Windows, the use of Docker is not the preferred solution. Instead, VM is preferred for Apps rich in GUI.
- Docker does not provide cross-platform compatibility.
What does that mean?
If an application is running on a docker container using Windows OS, it cannot be run on a container using Linux OS. Running OS should be the same.
- Sometimes it becomes difficult to manage a large number of containers.
- No solution for backup and data recovery.
Conclusion and Takeaways
So this is all about the Theory of Docker —
- Why do we need it?
- What Problem is it solving?
- Why was virtualization not a good solution though It was solving our Problem of sharing OS?
- Differences between Container and Images covered
- The ecosystem of Docker Covered
- Role of Docker Engine Covered
- Advantages and Disadvantages covered
In the next section, I will be covering all the docker commands I have used till now.
Thank you, and let me know in the comments if any correction is required!
References for Image Used: