What is Docker?

Docker:
Container strategy, tool for creating and managing containers
Container: Standardized unit of software (Built in the same image format, ex. Cakes in the same baking pan)
-A package of code and dependencies/tools to run that code
Ex. NodeJs Application with a container built with Docker (NodeJs: Javascript Runtime could be used to execute Javascript code in a server)
Can have Application Source code + NodeJS Runtime and any other tools that might be needed to run that code
-Same container with the same NodeJs code and tool will always give you the same behavior and result
-Support for containers are built into the modern operating systems
-Docker simplifies the creation and management of these containers

Real life Example
Picnic Box
Food + Dishes
Can share it with friend, have the same picnic box
Real Container
Standardized containers and we can fit various goods to the containers, but are stand alone(self contained and isolated)
Units of software, packages with code, dependencies to run the code, take it to anywhere docker runs, and be able to run exactly the same application with the same environment wherever that is

Why Containers?

Why would we want independent, standardized “application packages”?
Want to have the same environment for Development & Production
Different Development & Production Environments(We want to build and test in exactly the same environment as we later run our apps in) => We want to build and test in exactly the same environment as we later run our tests in
Ex: Created a Nodejs application and wrote codes there requires Nodejs version 14.3 to run successfully
Problem1: Different Development & Production Environments
We might have that version installed in local development environment
But when take this application and deploy it to a remote machine, on the remote machine we might have an older version of Nodejs version like 14.1 installed. Code worked locally doesn’t work on there and it would take time to find out what the problem is (Specific line of code)
Solution:
Lock a specific Node version into your docker container and ensure your code is executed in that exact version
Because your application runs in that container which brings its own Nodejs version
Problem2: Different Development & Production Environments

Easy to share a common development environment/setup with employees and colleagues
Different Development Environments within a Team or Company
=> Every team member should have the exactly same environment when working on the same project
Ex. We are in the big team, and now are working in the same project, the same Nodejs application.
You have older version of Nodejs and Other team member has a latest version
Then the recent code of the team member could not work on my environment

Clashing Tools/Versions Between different projects
Clashing Tools/Versions Between different projects => Ex. One project uses python version 2 and another project uses the latest version of python, the same with PHP or Nodejs
We will have clashing versions, so whenever switch from ProjectA to ProjectB, we have to uninstall and re-install the right version
Solution:
We lock our versions into the containers and every project has its own container, switch projects it will just work like that
Don’t need to uninstall and re-install because it is all in the container not globally on our host machine

Virtual Machine vs Docker

Solution: Virtual Machines/Virtual Operation Systems
-Why Docker and why containers?
Isn’t a problem reproduceable problem can be solved with Virtual machines(Machines running on our machines/Works with virtual os encapsulated in own shell independent from Host os )
Virtual Machine Structure
(1) Virtual Machine has Host OS(Windows/MacOS/Linux)
(2) On top of that, Virtual Machine is installed
-Computer inside our computer
-Virtual Machine has its o wn os (Virtual os that runs ins and outs the virtual machine)
-Inside the VM, extra tools can be installed, whatever we want (Libraries, Dependencies, and Tools we need)
(3) Source code can be moved
=> Have the same result as with Dockers / Containers
-Have encapsulated environment where everything is locked in and can have multiple environment for different projects
-Can share VM configuration with a colleague to ensure we are working on the same environment
Problem -Virtual Machine is like a stand-alone machine running on top of our machine. Brand new computer has to be set up in our machine => Eat up memory, CPU, and space on HDD, can be a problem when you have more VMS in our system.