Docker – 100+ Lab Exercises (Basic, Intermediate, Advanced)
🔰 Basic Level (30+ Exercises)
Goal: Grasp Docker fundamentals, image creation, and basic container orchestration.
Introduction to Docker
Install Docker on Linux/Windows/Mac.
Run your first Docker container (
hello-world).Explore
docker --version,docker info, anddocker help.Understand the difference between containers and VMs.
List running containers and images using CLI.
Working with Images
Pull and run official images (Nginx, Redis, Python).
Tag and remove images.
Inspect images with
docker inspect.Use
docker historyto view image layers.Search for images on Docker Hub.
Working with Containers
Start, stop, pause, and kill a container.
Create and use named containers.
Execute commands inside running containers (
docker exec).Copy files into and out of containers (
docker cp).View container logs.
Dockerfile Basics
Write a simple Dockerfile (Node.js, Python).
Build a Docker image using a Dockerfile.
Add environment variables using
ENV.Use
COPYandRUNinstructions.Use
.dockerignoreto exclude files.
🚀 Intermediate Level (40+ Exercises)
Goal: Master image optimization, volume and network usage, and multi-container setups.
Image Optimization
Minimize image size using Alpine base images.
Chain multiple
RUNcommands to reduce layers.Leverage multi-stage builds.
Use
.dockerignoreeffectively to exclude build context.Tag images with version numbers.
Docker Volumes
Create and mount a volume.
Persist data using named volumes.
Share volumes between containers.
Inspect and prune unused volumes.
Use bind mounts to sync local code.
Docker Networking
Create a custom bridge network.
Connect multiple containers via networks.
Use
docker inspectto analyze container IPs.Practice port mapping and exposing services.
Test container-to-container communication.
Docker Compose
Write a basic
docker-compose.ymlfor a web app and database.Use
depends_onto manage service order.Set environment variables via Compose.
Use volumes, ports, networks in Compose.
Scale services using
docker-compose up --scale.
Intermediate Workflows
Push and pull images from Docker Hub.
Automate builds using Docker CLI.
Practice
docker system prune.Build and deploy a basic MERN or LAMP stack.
Debug using
docker exec, logs, and healthchecks.
🧠 Advanced Level (40+ Exercises)
Goal: Engineer enterprise-grade Docker workflows, CI/CD integration, and Kubernetes-ready containers.
Security & Best Practices
Scan Docker images for vulnerabilities (Snyk, Trivy).
Use
USERto drop root privileges.Configure secrets securely via docker-compose or environment variables.
Implement container health checks.
Enforce read-only file systems.
Docker Registry & Automation
Set up a private Docker registry.
Push/pull images from a private registry.
Use
docker loginwith credential helpers.Automate tagging and pushing via GitHub Actions.
Configure Docker cache for CI/CD pipelines.
Advanced Dockerfile Patterns
Use
ARGfor dynamic build configurations.Break up Dockerfile into logical layers.
Implement custom entrypoint scripts.
Understand
CMDvsENTRYPOINT.Handle signals in containerized apps.
Multi-Container Architectures
Run microservices using Docker Compose.
Network Redis, PostgreSQL, and API service containers.
Deploy a complete WordPress + MySQL stack.
Use named volumes for each service.
Implement service discovery via Docker DNS.
Kubernetes Readiness
Generate production-ready container images.
Create
readinessProbeandlivenessProbe.Use labels and annotations on containers.
Prepare Docker images for Helm charts.
Migrate Compose YAML to Kubernetes manifests (Kompose).
Capstone Projects
Containerize a full-stack CI/CD pipeline.
Build and deploy a multi-service SaaS platform.
Secure and monitor containers with Prometheus and Grafana.
Set up reverse proxy using Traefik or Nginx.
Build a containerized ML inference pipeline.
✅ Tools & Technologies
Docker CLI, Docker Desktop
Docker Compose, Docker Registry
Snyk, Trivy, Hadolint
GitHub Actions, Jenkins, GitLab CI
Portainer, Rancher, Harbor
Kubernetes, Minikube, Helm
