Saturday, May 11, 2019

What do I really need? Vm ,Vagrant or Docker



If we are working on windows and our production environment is in Linux machine, then sometimes our code may give problems in the production environment. So, we need to set the development environment as same as production.

In order to do that we can install Virtual box (or any other VMware) in our host PC and install relevant Linux OS and install required software inside the VM and run our application exactly same as the production.

BUT...WE HERE STORIES LIKE...


  • IT works on my machine. But it is not working in other developers’ machine.
  • We have to spend a lot more time to setup the development environment.
  • Sometimes we use LAMP in development machine and production servers use individual installment, may cause issues.
  • Some software version issues or OS update may give issues. Ex: We both using windows 10. When I try to install MYSQL server, it causes errors but other developers machine not giving such bad experience(actually good experience 😊).
  • Since I am a newcomer to this company/team, I need more time to set up production similar environment.

So in order to remove those types of issues, we can use "Vagrant" which is a virtual machine manager. It allows you to script the virtual machine configuration as well as the provisioning.

In the following figure, VirtualBox is used as a platform to create VMs however Vagrant is used to configuring the VM by setting OS version, Network address, Memory allocation, number of CPUs assigned etc.

https://www.softqubes.com/blog/introduction-of-vagrant-development/

Still Not Clear ..How Vagrant apply in our day to day development?

Let's imagine a new developer come to our project. Then he/she needs to set up the development environment similar to our production environment which uses Redhat OS.
But that developer really familiar with Windows environment. So he needs VirtualBox to simulate the production environment while test the code. 

But we have to spend a considerable amount of time to correctly configure the production environment locally. 

WHAT IF FIVE NEW DEVELOPERS HIRED FOR URGENT PROJECT RESOURCE REQUIREMENT THEN WHAT DO YOU THINK ABOUT THIS TIME? 

Each and every developer need to do the same thing in their own machines. Isn't it?

Solution: Keep one scripting file which has same configuration details as production. When new developers hired then they need to execute provisioning script to set up the local development environment.

Practical Usage Of Vagrant
Step 01: Download the provisioning script and execute.
Step 02: Download project, build and test.

Problem: BUT...VIRTUALIZATION  COMES WITH  A COST

Ex: Each VM needs a separate OS.

Solution: Containerization

So, we can use Docker instead of  VM (it depends on situation. Sometimes vagrant is the best for your situation).
In docker, we configure everything to run the code and we create a docker image using those code and data. Then we deploy that container. So, we do not need individual OSs. Docker uses OS kernel so no more cost than VM.

Practical Usage Of Containerization
Step 01: Download project code with docker.
Step 02: Build docker image file
Step 03: Deploy it anywhere where docker container platform installed

How Doker Link With Cloud?

Step 01: Build docker image
Step 02: Upload image to Docker Hub
Step 03: Create containers based on application scalability needs

If you have any question, feel free to comment o it.


No comments:

Post a Comment