🚀 Cyber Security New Batch Start from 1 JunEnroll Now
Cyber Defence
Container Orchestration

Docker and Kubernetes

Complete Container Tutorial 2026

By Amit Kumar|May 26, 2026|14 min read
Docker and Kubernetes Tutorial - Container orchestration complete guide

Containerization has revolutionized how applications are developed, deployed, and managed in modern cloud environments

Introduction: The Container Revolution

Containerization has fundamentally transformed how applications are built, deployed, and managed in modern software development. Docker brought containers to the mainstream, and Kubernetes emerged as the orchestration standard for managing these containers at scale. Together, they form the foundation of modern cloud-native application deployment, enabling organizations to achieve unprecedented levels of agility, consistency, and efficiency.

In 2026, containerization skills have become essential for software engineers, DevOps professionals, and cloud architects. Whether you are deploying microservices, implementing CI/CD pipelines, or building cloud-native applications, understanding Docker and Kubernetes provides the foundation for modern application deployment. This comprehensive tutorial covers everything from container basics to production-grade cluster management.

The shift from monolithic applications to containerized microservices has created new architectural patterns and operational practices. Organizations embracing containerization report significant improvements in deployment frequency, lead time for changes, and mean time to recovery. Mastering these technologies opens doors to some of the most in-demand roles in the technology industry.

Understanding Docker: Container Fundamentals

Docker packages applications along with their dependencies into standardized units called containers. Unlike virtual machines, containers share the host operating system kernel, making them lightweight and fast while maintaining isolation from other processes.

Docker Architecture

  • 1.Docker Daemon: Background service managing containers, images, networks, and volumes
  • 2.Docker Client: CLI tool communicating with daemon via REST API
  • 3.Docker Registry: Storage for Docker images (Docker Hub by default)
  • 4.Objects: Images, containers, networks, volumes, and plugins

Container vs Virtual Machine

Size

Containers: MB range | VMs: GB range

Startup Time

Containers: seconds | VMs: minutes

Isolation

Containers: Process-level | VMs: Full isolation

Resource Usage

Containers: Minimal overhead | VMs: Significant overhead

Essential Docker Commands

Image Management

docker pull nginx:latest
docker images
docker rmi image_name
docker build -t myapp:v1 .
docker tag myapp:v1 repo/myapp:v1

Container Operations

docker run -d -p 80:80 nginx
docker ps -a
docker stop container_id
docker rm container_id
docker exec -it container bash

Creating Docker Images: Dockerfile Deep Dive

A Dockerfile is a text document containing instructions for building a Docker image. Each instruction creates a layer in the image, and the final image consists of all these layers stacked together.

Sample Dockerfile for Node.js Application

# Use official Node.js runtime as base
FROM node:20-alpine

# Set working directory
WORKDIR /app

# Copy package files first for better caching
COPY package*.json ./

# Install dependencies
RUN npm ci --only=production

# Copy application code
COPY . .

# Expose application port
EXPOSE 3000

# Environment variables
ENV NODE_ENV=production

# Health check
HEALTHCHECK --interval=30s --timeout=3s \
  CMD curl -f http://localhost:3000/health || exit 1

# Start the application
CMD ["node", "server.js"]

Key Dockerfile Instructions

FROM - Base Image

Specifies the base image to use. Always start with FROM. Use Alpine variants for smaller images.

COPY and ADD - File Operations

COPY is preferred for local files. ADD supports remote URLs and tar extraction. COPY is explicit and preferred.

RUN - Commands During Build

Executes commands during image build. Use for installing packages, compiling code, and configuration.

CMD and ENTRYPOINT - Runtime Commands

CMD defines default command (can be overridden). ENTRYPOINT configures container to run as executable.

ENV and ARG - Variables

ARG defines build-time variables. ENV defines runtime environment variables visible in the container.

Docker Container Architecture - How containers work under the hood

Docker containers share the host kernel while maintaining process isolation, making them lightweight and secure

Docker Compose: Multi-Container Applications

Docker Compose defines and runs multi-container applications. With a single YAML file, you can define services, networks, volumes, and their configurations, then spin up the entire stack with one command.

docker-compose.yml Example

version: '3.8'

services:
  web:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "3000:3000"
    environment:
      - NODE_ENV=production
      - DB_HOST=postgres
    depends_on:
      - postgres
      - redis
    restart: unless-stopped

  postgres:
    image: postgres:15-alpine
    volumes:
      - postgres_data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=myapp
      - POSTGRES_USER=admin
      - POSTGRES_PASSWORD=${DB_PASSWORD}
    restart: unless-stopped

  redis:
    image: redis:7-alpine
    volumes:
      - redis_data:/data
    restart: unless-stopped

volumes:
  postgres_data:
  redis_data:

Common Docker Compose Commands

docker-compose up -d
Start all services in background
docker-compose down
Stop and remove containers
docker-compose logs -f web
Follow logs from web service
docker-compose exec web bash
Open shell in running container
docker-compose ps
List running services

Kubernetes: Container Orchestration at Scale

Kubernetes (K8s) is an open-source container orchestration platform that automates deployment, scaling, and management of containerized applications. Originally developed by Google and now maintained by the Cloud Native Computing Foundation, Kubernetes has become the industry standard for production container management.

Kubernetes Architecture Overview

Control Plane (Master)

kube-apiserver

Exposes Kubernetes API, front-end for control plane

etcd

Consistent, highly-available key-value store for cluster state

kube-scheduler

Assigns pods to nodes based on resource availability

kube-controller-manager

Runs controller processes regulating cluster state

Worker Nodes

kubelet

Agent on each node ensuring containers are running

kube-proxy

Network proxy maintaining network rules

container runtime

Software for running containers (containerd)

Core Kubernetes Objects

Pod

Smallest deployable unit. One or more containers sharing network and storage. Pods are ephemeral.

Deployment

Manages ReplicaSets and provides declarative updates for pods. Supports rolling updates and rollbacks.

Service

Stable network endpoint for accessing pods. Load balances across multiple pod replicas.

Ingress

HTTP/HTTPS routing to services. Manages external access with SSL termination and host-based routing.

ConfigMap & Secret

Configuration data and sensitive information. Decouples configuration from container images.

PersistentVolume

Storage that persists beyond pod lifecycle. Supports various backends including NFS, cloud storage, and local disks.

Kubernetes Deployment Examples

Understanding Kubernetes through practical examples accelerates learning. Here are common deployment patterns with corresponding YAML configurations.

Deployment YAML Example

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-app
  labels:
    app: web-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web-app
  template:
    metadata:
      labels:
        app: web-app
    spec:
      containers:
      - name: web-app
        image: myapp:v1
        ports:
        - containerPort: 3000
        resources:
          requests:
            memory: "128Mi"
            cpu: "250m"
          limits:
            memory: "256Mi"
            cpu: "500m"
        livenessProbe:
          httpGet:
            path: /health
            port: 3000
          initialDelaySeconds: 10
          periodSeconds: 5
        readinessProbe:
          httpGet:
            path: /ready
            port: 3000
          initialDelaySeconds: 5
          periodSeconds: 3

Service YAML Example

apiVersion: v1
kind: Service
metadata:
  name: web-app-service
spec:
  type: LoadBalancer
  selector:
    app: web-app
  ports:
  - protocol: TCP
    port: 80
    targetPort: 3000
  - protocol: TCP
    port: 443
    targetPort: 3000

Essential kubectl Commands

kubectl get pods -o wide
List all pods with details
kubectl describe pod name
Show pod details
kubectl apply -f deployment.yml
Create/update resources
kubectl logs -f pod/name
Follow pod logs
kubectl exec -it pod -- bash
Open shell in pod
kubectl scale deployment web --replicas=5
Scale deployment
kubectl rollout status deployment/web
Check rollout progress
kubectl rollout undo deployment/web
Rollback to previous version

Helm: Kubernetes Package Manager

Helm simplifies Kubernetes deployments by packaging resources into charts. Charts are reusable, versioned configurations that can be shared through repositories. Helm brings templating, versioning, and dependency management to Kubernetes manifests.

Helm Commands

helm repo add bitnami https://charts.bitnami.com/bitnami
Add chart repository
helm install myapp bitnami/nginx
Install chart
helm upgrade myapp bitnami/nginx -f values.yml
Upgrade release
helm rollback myapp 1
Rollback release
helm list
List installed releases
helm uninstall myapp
Remove release

Frequently Asked Questions

What is Docker and why should I learn it?

Docker is a containerization platform that packages applications and their dependencies into lightweight, portable containers. Learning Docker is essential because it standardizes application deployment, eliminates the 'works on my machine' problem, and enables consistent development and production environments.

What is Kubernetes and how does it relate to Docker?

Kubernetes is a container orchestration platform that manages containerized applications at scale. While Docker creates and runs individual containers, Kubernetes coordinates multiple containers across clusters of machines. Docker provides the containers that Kubernetes orchestrates, making them complementary technologies.

How long does it take to learn Docker and Kubernetes?

For Docker fundamentals, approximately 2-4 weeks of focused learning is sufficient for basic container management. Kubernetes proficiency typically requires 2-3 months of dedicated study, including understanding core concepts, working with kubectl, and deploying applications.

What are the prerequisites for learning Docker and Kubernetes?

Prerequisites include basic Linux command-line proficiency, understanding of basic networking concepts, familiarity with version control with Git, and basic understanding of how web applications work. Python or another programming language familiarity is helpful but not required.

What is the difference between Docker Swarm and Kubernetes?

Docker Swarm is Docker's native container orchestration solution, while Kubernetes is a standalone platform. Kubernetes offers significantly more features including advanced scheduling, auto-scaling, rolling updates, and persistent storage orchestration. Kubernetes has become the industry standard for production container orchestration.

Related Resources

Master Docker and Kubernetes

Cyber Defence offers comprehensive Docker and Kubernetes training with hands-on labs, real-world scenarios, and Kubernetes Administrator certification preparation.