0% found this document useful (0 votes)
14 views17 pages

Evolution from VMs to Containers

Uploaded by

ashis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views17 pages

Evolution from VMs to Containers

Uploaded by

ashis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

The evolution from Virtual Machines (VMs) to containers is a story of increasing

efficiency, scalability, and agility in software development and deployment. Let’s break it
down step by step:

1. The Era of Physical Servers (Pre-2000s)

●​ How it worked: Applications ran directly on physical servers.


●​ Problems:
○​ Underutilization: Servers often ran at low capacity, wasting resources.
○​ Scalability Issues: Adding new applications required new hardware.
○​ Dependency Conflicts: Applications with conflicting dependencies
couldn’t run on the same server.

2. The Rise of Virtual Machines (2000s)

"Imagine you have a computer and you used to run a single application. Now, you want to run
three different applications. Each app needs its own environment, with different software
versions. In the old days, we used Virtual Machines (VMs) for this."

You draw a picture on the board:

●​ A big server at the bottom


●​ Several Virtual Machines (VMs) on top
●​ Each VM has its own operating system

VM Architecture Diagram
How VMs Work?

1.​ The Hypervisor virtualizes physical hardware.


2.​ Each VM gets allocated CPU, RAM, disk, and network resources.
3.​ VMs run independently, as if they are separate machines.
4.​ A Host OS (if present) interacts with the hypervisor to manage VMs.

What is a Hypervisor?

A Hypervisor is software or firmware that allows you to create and manage virtual machines
(VMs) by virtualizing hardware resources like CPU, memory, and storage.

It sits between the physical hardware and the virtual machines, ensuring that each VM gets
its allocated resources while remaining isolated from others.

●​ VMware ESXi
●​ Microsoft Hyper-V
●​ KVM (Kernel-based Virtual Machine)
●​ Xen
●​ KVM based Nitro Hypervisor used in AWS

AWS Nitro Hypervisor (Used in Newer EC2 Instances)

●​ AWS-developed lightweight hypervisor based on KVM.


●​ Replaces Xen, which AWS used earlier.
●​ Better performance: Removes virtualization overhead.
●​ Used in Nitro-based EC2 instances (T3, C5, M5, etc.).
"But there’s a problem," when you continue

1.​ "Each VM is heavy, takes a lot of time to start, and wastes system resources. If you
just wanted to run a simple app, you had to carry the entire OS with it. Like carrying a
whole house just to move your bed!"

The students laugh. They get the point.

2.​ "It works on my machine": You set up the application on Windows but your friend or
tester has linux. The app won’t run in your friends’ computer

3. The Birth of Containerization (2010s)

1. What is a Container?

A container is a lightweight, standalone, and executable software package that includes:

●​ Code (your app)


●​ Runtime (e.g., Python, [Link])
●​ System tools & libraries
●​ Settings & dependencies

Key Features:​

Isolated – Runs in its own space, separate from other apps.​

Portable – Works the same on any machine (laptop, cloud, server).​

Fast & Efficient – Shares the host OS kernel (unlike VMs).

Example:

Think of a shipping container:

●​ It holds goods (your app).


●​ It works on any ship, train, or truck (any computer).
●​ It doesn’t care what’s outside—it just runs what’s inside.
●​ Early Container Technologies:
○​ 2006: cgroups (Control Groups): Introduced by Google in Linux to limit
and isolate resource usage (CPU, memory, disk I/O) for processes.
○​ 2008: LXC (Linux Containers): The first complete container management
solution, combining cgroups and namespaces for process isolation.

4. Docker: The Game-Changer (2013):

Docker was introduced by Solomon Hykes and his team at DotCloud, a


platform-as-a-service (PaaS) company. Docker was first released to the public in March
2013 as an open-source project during the PyCon conference in Santa Clara, California.
Docker is a platform that helps create, run, and manage containers.

What is Docker?
○​ Docker is a platform for building, shipping, and running containers.
○​ It simplified containerization by providing a user-friendly interface and
tools.
Why Docker Took Off:
○​ Ease of Use: Docker made containers accessible to developers with
simple commands and a clear workflow.
○​ Solves the "It works on my machine!" problem.
○​ Makes deploying apps faster and easier.
○​ Docker Hub: A centralized repository for sharing container images.
○​ Ecosystem: Docker introduced tools like Docker Compose, Docker Swarm,
and Docker Desktop.
○​ Used by developers and companies worldwide (like Google, Netflix).

Impact:
○​ Docker popularized containerization and became the de facto standard for
containers.
○​ It paved the way for modern DevOps practices and cloud-native
development.
5. The Rise of Kubernetes and Container Orchestration (2014-Present)
●​ What is Kubernetes?
○​ Kubernetes is an open-source platform for automating the deployment, scaling,
and management of containerized applications.
●​ Why Kubernetes?
○​ As container adoption grew, managing large-scale container deployments
became challenging.
○​ Kubernetes provided tools for orchestration, load balancing, and self-healing.
●​ Impact:
○​ Kubernetes became the standard for container orchestration, especially in cloud
environments.
○​ It works seamlessly with Docker and other container runtimes (e.g., containerd,
CRI-O).

6. The Modern Container Ecosystem


●​ Container Runtimes:
○​ Docker: Still widely used, but its runtime (dockerd) is being replaced by
containerd in Kubernetes.
○​ Podman: A daemonless, rootless alternative to Docker.
○​ CRI-O: A lightweight runtime designed for Kubernetes.
●​ Orchestration Tools:
○​ Kubernetes dominates, but alternatives like Docker Swarm and Nomad exist.
●​ Serverless and Edge Computing:
Other Container Technologies:

●​ Podman (Red Hat alternative to Docker)


●​ LXC (Linux Containers) – used in early containerization
●​ Kubernetes (Manages multiple containers)

Docker Installation (Linux):

Run First Docker Command


$ docker run hello-world
$ docker ps (permission denied)

It doesn’t work in AWS:


A docker group has been created $ cat/etc/group

$ sudo usermod -aG docker $USER


$cat /etc/group
$ docker ps (permission denied)
$ sudo reboot
$ docker run hello-world

Run in terminal:

$ docker run bongodev-hello-app


3. Docker Architecture & Components

Docker follows a client-server architecture:

1. Docker Daemon (dockerd)

●​ The background service that manages containers, images, networks, and


storage.
●​ Listens for Docker API requests.

2. Docker Client (docker CLI)

●​ The command-line tool you use to interact with Docker (e.g., docker run).
●​ Sends commands to the Docker Daemon.

3. Docker Images

●​ Read-only templates used to create containers (like a blueprint).


●​ Example: ubuntu, nginx, python:3.9.

4. Docker Containers

●​ Running instances of Docker images.


●​ Example: docker run -it ubuntu bash → Starts an Ubuntu container.

5. Docker Registry (Docker Hub)

●​ A storage system for Docker images (like an app store).


●​ Default registry: Docker Hub.
6. Dockerfile

●​ A text file with instructions to build a Docker image.

Key Concepts
●​ Image: A snapshot of an application and its dependencies. Blueprint for
containers
●​ Container: A running instance of an image.
●​ Dockerfile: A script to build Docker images.
●​ Volume: Persistent storage for containers.
●​ Network: Communication between containers. (default network driver for
Docker containers: Bridge)
4. How Docker Works (Step-by-Step Flow)

You write a Dockerfile (instructions to build an app).​

Build an image:

$ docker build -t myapp .

Run a container from the image:

$ docker run -d -p 8080:80 myapp

Docker Daemon creates and manages the container.​

Your app runs inside the container, isolated but using the host OS.

How Many tool Does a DevOps Engineer Need to Know (a couple of them):
[Link]

Key Benefits of Docker

Consistency – No more "Works on my machine!" issues.​

Isolation – Apps don’t interfere with each other.​

Portability – Run anywhere (Linux, Windows, Cloud).​

Scalability – Easy to deploy multiple containers (e.g., Kubernetes).​

Fast Deployment – Spin up apps in seconds.


Common Use Cases

●​ Microservices (breaking apps into small containers).


●​ CI/CD Pipelines (automated testing & deployment).
●​ Development Environments (same setup for all devs).
●​ Cloud Deployment (AWS, Azure, Google Cloud).
Docker & Container Cheatsheet

Docker Lifecycle

Command Description

docker run <image> Run a container from an image

docker start <container> Start a stopped container

docker stop <container> Stop a running container

docker restart <container> Restart a container

docker pause <container> Pause a running container

docker unpause <container> Unpause a container

docker kill <container> Force-stop a container

docker rm <container> Remove a stopped container

docker rm -f <container> Force-remove a running container


Container Management

Command Description

docker ps List running containers

docker ps -a List all containers (including stopped)

docker logs <container> Show container logs

docker logs -f <container> Follow logs in real-time

docker exec -it <container> <command> Run a command inside a running

container

docker attach <container> Attach to a running container

docker inspect <container> Show detailed container info

docker top <container> Show running processes in a container

docker stats Show live container resource usage


2. Image Management

Command Description

docker images List all images

docker pull <image> Download an image from a

registry

docker push <image> Upload an image to a registry

docker build -t <name> . Build an image from a Dockerfile

docker rmi <image> Remove an image

docker history <image> Show image layers

docker save <image> > [Link] Save an image to a tar file

docker load < [Link] Load an image from a tar file


3. Networking

Command Description

docker network ls List all networks

docker network inspect <network> Inspect a network

docker network create <name> Create a new network

docker network connect <network> Connect a container to a


<container> network

docker network disconnect <network> Disconnect a container


<container>

Port Mapping

$ docker run -p <host_port>:<container_port> <image> # Map host port to container


port
4. Volumes & Storage

Command Description

docker volume ls List all volumes

docker volume create <name> Create a volume

docker volume inspect <name> Inspect a volume

docker volume rm <name> Remove a

volume

Mounting Volumes

$ docker run -v <host_path>:<container_path> <image> # Bind mount

$ docker run -v <volume_name>:<container_path> <image> # Named volume


5. Docker Compose

Command Description

docker-compose up Start services defined in [Link]

docker-compose up -d Start in detached mode

docker-compose down Stop and remove containers, networks, and

volumes

docker-compose ps List running services

docker-compose logs Show logs for services

docker-compose build Rebuild images

6. Dockerfile Cheatsheet

Common Instructions

dockerfile

FROM <image> # Base image


RUN <command> # Execute a command during build
COPY <src> <dest> # Copy files from host to container
ADD <src> <dest> # Copy + extract archives
WORKDIR <path> # Set working directory
ENV <key>=<value> # Set environment variables
EXPOSE <port> # Declare exposed ports
CMD ["executable"] # Default command to run
ENTRYPOINT ["executable"] # Configure a container to run as an executable
7. Tips & Tricks

●​ docker system prune → Remove unused containers, networks, and images.


●​ docker exec -it <container> sh → Open an interactive shell in a container.
●​ docker cp <container>:<path> <host_path> → Copy files from container to
host.
●​ Use --name to assign a custom name to a container.
●​ Use --restart=always to auto-restart containers on failure.

You might also like