What is Docker and what's so special about it?

How often have you heard of problems between developers and clients with the highlight being “It works on my machine!” ?

Well, it used to be more common than you’d think!

What changed? Docker!

(TLDR at the bottom!)

Docker, the Savior!

Docker is a platform for building applications based on containers . This helps increase the application portability by creating lightweight execution environments sharing the OS kernel.

Too complicated explanation to understand its need? Well, let’s see what it was like before Docker to understand why we need Docker.

The need for isolated environments

How development earlier worked, and is still common today for many developers, is they would create the application in their own machine and would then send the source code along with software and hardware dependencies to their client. And here the age-old discussions started: the developer repeatedly asserting that “It works on my machine!” and asking the client to recheck their software dependencies.

→ A very common reason why these things occur is that maybe some of the several dependencies required in the software might be pre-installed in the developer’s workstation before he/she started working on the software and therefore, forgot to account it as a requirement for the project.

→ Another reason might be that the client has multiple software in his/her PC and there might be some dependencies pre-installed but there could be a version mismatch and if one is updated, then the other project might not work.

Virtual Machines: A solution

All this called for an efficient isolated system for each application. Think of it as a PC with just one application on it so there might be no interference with other applications and when called for, the developer will just hand over the one-app PC to the client and there will be no problems in running the application.

Crazy, right? We can’t just hand over new PCs for all applications.

But, what if we can? Virtually, of course. That’s how the concept of Virtual Machines(VMs) comes to use. VMs allow us to have multiple Guest OS built on existing infrastructure where we can work on our application with each application having its own OS and thus each application will work in isolation by sharing hardware but having individual software. A software known as hypervisor is responsible for creating and running virtual machines.

Okay… Sounds good…. Seems like the problem is solved! But I still didn’t get the need for Docker in this and am still not sure what a container is 🤷🏼‍♂️.

Magic of Containers!

Hosting Guest OS is no simple thing! It is a very resource-heavy solution. Each OS is GBs in size and pretty difficult to maintain. And this is where a container can be useful.

Containers can provide isolated execution environments to applications but share an OS kernel. This allows them to be very small, typically in MBs. The use of containers allows us to avoid the 99.9% stuff in VMs that mostly go unused due to the high space requirement of Guest OS. Containers also start-up almost immediately which is far far better than a VM; which boots an OS, so that takes up a lot of time. Containers can just be spun up and down in a fraction of second. In fact, just to let you have an estimate of a container’s speed and also how old the containerization technology actually is, let me tell you a very interesting fact.

Fact: Every time you search for something on Google, a new container is created. In fact, everything at Google runs on containers! It spins up thousands of containers every second!!!

How does Docker use containers?

Now with the above explanation in mind, let’s read the Docker definition mentioned above again.

Docker is a platform for building applications based on containers . This helps increase the application portability by creating lightweight execution environments sharing the OS kernel.

So, Docker is a software that enables the developer to easily create and maintain containers and container-based apps(containerized apps).

How to port applications with Docker?

Once you have created a containerized app in Docker, you can build its Docker image with a simple command of docker build and a docker-image will be created for you which you can then upload onto Docker Hub or just send to your client.

A docker-image can easily be loaded onto Docker and run the application easily. Voila!

No dependencies errors whatsoever. It will run onto the client’s machine exactly as it did on the developer’s machine as, technically, it has the same environment due to docker-image.

Conclusion

Problem: Different execution environments on different machines for Softwares leading to several dependency problems

Solution: Create an isolated execution environment for each application

Inefficient Implementation: Create virtual machines so each application has its own OS.

Efficient Implementation: Use Docker to spin up containers to provide the applications isolated execution environments while sharing the same OS kernel. Also improves application portability.

If you're really interested and want to learn more about how to use Docker, go here .

Please post your feedback in the comments below.

Happy Learning!