1. Docker and containerization high level concepts
1.1 What is Docker and containers?
- Containerization → Building self-sufficient software packages that perform consistently regardless of the machines they run on. It’s basically taking a snapshot of a machine along with the filesystem and letting you use and deploy it as a construct.
- Docker → Created a standard for building and deploying containers to make our lives easy. They did it by making deploying containers very easy and by allowing container orchestration which makes deployment simple.
1.2 Why containerization
- Everyone has different OS → Installing dependencies on different os has different steps and cannot be generalized, hence setting up a project becomes difficult. Managing project dependencies as the application scales is difficult due to different os version compatibilities.
- What if there was a way to describe your projects configuration in a single file → Instead of running
npm install … for different libraries, we run a single docker command that installs all dependencies.
- What if we could run the application in an isolated environment → An environment that has an allocated RAM, ROM, processors, etc that are used to run the application in an isolated environment reduces, I would say eliminate system permission conflicts and other security walls that stop development of the application and vice versa.
- This would make a local setup of open source a breeze → Cloning an open-source project becomes easy as the env setup is handled by docker and the exact replica of the project is made with the system configurations, so people can focus on building rather than setting up.
- Makes installing and deletion of auxiliary services easier than ever → to delete the environment or create a new one is extremely simple.
1.3 Three major parts of docker
- Command Line Interface (CLI) → To interface with docker daemon
- Engine → The guy who makes and manages the mini images, the important part of docker.
- Registry
DockerHub → Deploy machine-images this registry for others to pull. Aws, gcp, etc have their own too!
1.4 Images v/s containers
A docker image behaves like a template from which consistent containers can be created.
Consider this example → Windows 10 & Acer, here windows 10 is an iso file that has windows explorer, the code for running and installing the os, setting up the system variables and env, the basic setup for the user, etc, this is the iso and this is what we call an image. A container is an Acer Nitro 5 laptop that can run windows 10 properly and efficiently, this is what we call as container. It has an allocated ram, rom, processor, storage, etc that can be utilized by the iso i.e. the image.
Basically,
**Image** → ISO
**Container** → Running an ISO
**Image while running -> Container**