A Virtual Machine a day keeps the Docker away
Tags: docker, beginners
Published: 2022-05-02 13:07:55

**What is docker?**
Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers. These containers can run reliably in any environment. 

**What does that mean?**
When you've build an app on your machine running windows and you now need to test your app with one of your testers, but they are using an entirely different system. How can replicate the environment your software needs on any machine? That's where Docker, or any other containerization platform comes in.

Once upon a time if you wanted to run or start any web application you'd have to start off buying a physical server. Once your server was configured and running your application, you may want to expand and setup multiple servers to help manage traffic to your application and ensure you don't crash, so you buy and setup more physical servers. Well, that process was all taken into the virtual world with the introduction of cloud based computing. We were able to find a way to setup these physical servers, virtually in the form of virtual machines. We would use software called hypervisors to divide our server's physical resources into separate self contained virtual machines, each with their own OS, CPU, Memory resource, and most importantly, it's own kernel (the core of a system's operating system. Operating System is a system software. Kernel is system software that is part of the operating system. Operating System provides interface between **user and hardware**. Kernel provides interface between **applications and hardware**.).  Now lets say we wanted to do that for 3 different applications on our server, if would look something like this:
![virtual machine description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k4szfgprnzik1zmfn7ti.PNG)
 

All those virtual machines take up a lot of resources and also take a while to start and setup, each needing it's own copy of various libraries to lay the groundwork for your applications. The introduction of Docker Containers changed that. Instead, Docker containers are able to carry a lot less resources while still maintaining it's ability to run the application quickly, and in a quarantined state by allowing all the resources to flow through one kernel. The Docker Engine uses something called the docker daemon (which in my understanding, functions similarly to the hypervisors with virtual machines) to act as a sort of 'brain' for your docker. It will manage the docker image itself and help allocate resources from your host machine, looking something like this: 

![docker container description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7mgcvfcfz8dkbuhx5wib.PNG)
 
Since each docker container doesn't have to contain it's own OS, the docker daemon is able to communicate directly with the host machine's OS and allocate the appropriate resources for running each container. It also ensures each container is still isolated from the host machine and other containers. We're saving a ton of disk space by not saving a separate OS in each container.

These containers are ultra portable. A container has all of the information and dependencies needed for your application to run and can be run on any system environment with the same result. You can now send your container to your testers and regardless of the system they're running your app should perform as expected on the host machine.

Similar to how NPM is both an application and a library, Docker offers an extensive library of applications and builds that come pre-packaged for you  as a docker container called the Docker Hub. The Docker Hub is a public repo of Docker images that boasts over 100,000 container images from software vendors, open-source projects, and individual developers alike. One day, even you could have your very own application image hosted on the Docker Hub for other users to pull down and tinker around with. I hope this brief explanation of Docker and it's uses has shed some light on the power of docker and it's uses in web development and deployment.