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, and docker 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 history to 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 COPY and RUN instructions.

  • Use .dockerignore to 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 RUN commands to reduce layers.

  • Leverage multi-stage builds.

  • Use .dockerignore effectively 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 inspect to analyze container IPs.

  • Practice port mapping and exposing services.

  • Test container-to-container communication.

Docker Compose

  • Write a basic docker-compose.yml for a web app and database.

  • Use depends_on to 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 USER to 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 login with credential helpers.

  • Automate tagging and pushing via GitHub Actions.

  • Configure Docker cache for CI/CD pipelines.

Advanced Dockerfile Patterns

  • Use ARG for dynamic build configurations.

  • Break up Dockerfile into logical layers.

  • Implement custom entrypoint scripts.

  • Understand CMD vs ENTRYPOINT.

  • 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 readinessProbe and livenessProbe.

  • 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

Scroll to Top