Docker

Docker is an open-source project based on Linux containers for developing, shipping, and running applications.

Containers are lightweight, portable, and self-sufficient units that can run applications and their dependencies, ensuring consistency across different environments.

Docker provides the ability to package and run an application in a loosely isolated environment

Docker provides a standardized way to package, distribute, and deploy software, making it easier to build, ship, and run applications reliably across various computing environments.

It uses Linux Kernel features like namespaces and control groups to create containers on top of an operating system.

  • Namespaces –> deal with resource isolation for a single process, allocate - pid, username
  • Cgroups –> manage resources for a group of processes, allocates - cpu, memory

Together, cgroups and namespaces were used to create a container technology called Linux Containers(LXC)

  • Light-weight version of VM
  • Runtime is less, Don’t need to boot os
Host(OS)
	|--Docker Engine	
		|--Container
		|--Container

Virtualization

Problem statement

  • It works in my machine
  • Soln –> Isolation
    • Physical
    • Virtual Machine
    • Container

Physical Machine

  • Requirement
    • One physical machine
  • Runs
    • One OS, One APP
  • Problems
    • Huge Cost
    • Slow Deployment
    • Hard to Migrate
Hardware
	|-- Operating System
		|-- Runtime Environment
			|-- Application

Virtual Machine(VM)

  • Hypervisor-based Virtualization
    • Traditional methods of virtualization
    • Eg: VMware, Virtual Box, AWS, Azure
  • VM are bulky—typically gigabytes in size.
    • On top we install OS
    • It’s resource hungry
  • Requirement
    • One physical machine
  • Runs
    • One/more OS and APP in different VM
  • Benefits:
    • Cost-Efficient
    • Easy to Scale
  • Limitations:
    • Kernel Resource Duplication
      • RAM , Memory wastage
    • Application Portability Issue
Hardware
  |--HOST OS
	  |--VM
	  |	|--Guest OS
	  |	    |--Runtime Environment
	  |		    |--Application
	  |		
	  |--VM
	  |	|--Guest OS
		    |--Runtime Environment
			    |--Application

Container

  • Requirement
    • One physical machine
  • Runs
    • One OS
    • One or more Apps in different containers
  • Benefits:
    • Cost-Efficient
    • Fast Deployment
    • Guaranteed Portability
Hardware
  |--Host OS
      |--Container
	  |    |--Runtime Environment
	  |    	  |--Application
	  |	
	  |--Container
	  |    |--Runtime Environment
	  |    	  |--Application

Docker Feature

Sometimes application that runs in 1 platform but fail in other, tdoes not happen with docker

  1. Ease of use
    • To take advantage of containers in order to quickly build and test portable applications.
    • The mantra is: build once, run anywhere
  2. Speed
    • Docker containers are very lightweight and fast
  3. Docker Hub
    • Docker Hub, which you can think of as an “app store for Docker images.”
  4. Modularity and Scalability
    • Docker makes it easy to break out your application’s functionality into individual containers.
  5. Portability
  6. Isolation

Virtualization and Containerization

On the virtualization side, we have open-source platforms like Xen and KVM. Then there’s VMware vSphere, Microsoft Hyper V, Oracle’s Virtual Box, and more.

For containers, Docker is the most popular container engine right now. We also have alternatives like rkt, Podman, and Containerd. When it comes to container orchestration, options include Kubernetes, Docker Swarm, and Nomad.

When use VM?

If you need to run multiple applications on multiple servers, it probably makes sense to use VMs.

When use Docker?

  • If you need to run many copies of a single application then docker offers some compelling advantages.
  • Security has also been an area of concern with Docker containers since containers share the same kernel, the barrier between containers is thinner.

Reference