Docker vs Virtual Machine

A virtual machine is one where multiple operating system are installed on a single operating system and each of the operating system running on their own system. Problem with traditional VMs are they are heavy weight and you don’t want to run too many on the single system as it just overloads everything. Docker brings abstraction up one level, it’s not operating system at that level and its more on to application level. Docker is a self-contained space for applications to run. All it really is a command line tool where you can just say docker run and the name of the application like PHP, bash etc…

Structuring Application

With structuring your apps  Docker lets you contain the app in a certain space which is interesting because when I would normally create a web application, I would install a bunch of random programs onto the server after a while I didn’t really know what I had installed on there and one thing I always thought was well I have this website with a bunch of software and tools and installed programs on a certain machine and for example if I ever wanted to sell this website to somebody else I always wondered how would I do that. 

With docker I can take this website and contain it in a container as an image and that is essentially the whole application and It can be deployed with this image on any other server and duplicate the website functionality.

Portability

Next great thing about it is portability the way docker is used is you have instructions indicating how to set up a server just the way you need it so I will always be able to know exactly how a server is set up as long as I’m creating the app the docker way like I might say that website requires a certain technology stack like python version 2.7. 

I can specify all that and that would say that the configuration files need to be done this certain way and all of that can be contained in a certain container so it makes it clear exactly what are the configurations to get a website to work if it works for me it’s going to work for you or anybody else and it gets rid of that world where I might have Python version 2.7 installed you have Python version 3 and  I copied the code over to your server and it doesn’t work.

MicroServices

Structurally for coding, Docker really promotes the usage of microservices which is a recent trend so micro-services are the idea that you have many different services that each do a single task. As you can imagine this would lend itself very well for scaling. 

In reality most people aren’t going to code this way because it’s just too expensive to be provisioning new servers for every little service you want to offer what happens is you just install everything on one single machine and then this one single machine is overloaded with a bunch of random technology and you’ve eventually get  everything all mixed up together and pretty soon you don’t really know what you’ve got on the system anymore. 

With docker and containerization you can create separate spaces for each of these services and that allows you to really separate out your program and think in that way and lets you code in that manner.

Scalability

Another great thing this is so good is it scales very easily. Docker comes with a whole set of tools for deploying this across many clusters you can take your instances of each micro service that you have in each container and then allocate many machines to them specify how many of the resources of each machine you want specify rules about how they should scale what should happen if they crash and it all scales up very nicely and makes everything scalable.

Web servers are very powerful these days and usually what’s going to be your bottleneck is your database server for various reasons people still don’t quite recommend putting your database server in the container and the reason is that containers can crash, and you just want that to be as efficient as possible. Database servers also use persistent storage which makes it less easy to scale because every instance is still dependent on this one single storage anyway.

#10DayOf100DaysOfCode      

 

Last modified: March 20, 2019

Author

Comments

Write a Reply or Comment

Your email address will not be published.