Containerization & Docker in Virtualized
Environments
2. Introduction to Containerization
What is Containerization?
Lightweight, portable, and scalable alternative to Virtual Machines (VMs).
Containers share the host OS kernel, reducing overhead.
Popular container runtime: Docker, Podman, LXC.
Benefits of Containerization
Portability – Run applications anywhere.
Efficiency – Uses fewer resources than VMs.
Scalability – Easily scale services in cloud environments.
Isolation – Secure and self-contained applications.
3. Introduction to Docker
What is Docker?
Open-source containerization platform for building, running, and managing containers.
Uses Docker Engine to manage lightweight, isolated applications.
Supports Docker Hub, a public repository for container images.
Key Docker Concepts
• Images – Pre-configured environments (e.g., Ubuntu, Nginx).
• Containers – Running instances of Docker images.
• Dockerfile – Script to automate image creation.
• Volumes – Persistent storage for containers.
• Networking – Connects containers internally and externally.
4. Lab Activity: Installing Docker & Running Containers
Step 1: Install Docker on Linux
Update the system:
sudo apt update && sudo apt upgrade -y
Install Docker:
sudo apt install docker.io -y
Enable and start Docker:
sudo systemctl enable --now docker
Verify installation:
docker --version
Step 2: Run a Simple Docker Container
Pull an Ubuntu image:
docker pull ubuntu
Run a container from the image:
docker run -it ubuntu /bin/bash
Verify running containers:
docker ps
Step 3: Build a Custom Docker Image
Create a Dockerfile:
FROM ubuntu
RUN apt update && apt install -y nginx
CMD ["nginx", "-g", "daemon off;"]
Build the Docker image:
docker build -t my-nginx .
Run the custom container:
docker run -d -p 8080:80 my-nginx
Test the container:
curl http://localhost:8080
5. Docker Networking and Storage
1. Networking in Docker
Bridge Network – Default network, allows communication between containers.
Host Network – Directly connects to the host’s network.
Overlay Network – Used in Docker Swarm for multi-host networking.
List networks:
docker network ls
Create a new network:
docker network create my_network
Run a container on the new network:
docker run -d --name my_app --network my_network nginx
2. Docker Volumes (Persistent Storage)
Volumes allow containers to store and share data.
Used when data needs to persist beyond the container’s lifecycle.
Create a volume:
docker volume create my_volume
Attach the volume to a container:
docker run -d -v my_volume:/data nginx