Skip to content

hatamiarash7/learn-docker

Repository files navigation

🐳 Learn Docker

A comprehensive, hands-on Docker learning course designed for practical classroom use. This repository contains exercises, examples, and projects to help students master Docker from basics to advanced concepts.


πŸ“‹ Course Overview

This course covers everything you need to know to work with Docker effectively:

Section Topics
1. Starting with Docker Installation, first containers
2. Docker Images Pull, push, tag, save/load
3. Build Your Own Images Dockerfiles, multi-stage builds
4. Managing Containers Lifecycle, logs, resources
5. Networking Bridge, host, custom networks
6. Docker Compose Multi-container applications
7. Storage & Volumes Volumes, bind mounts, persistence
8. Docker Swarm Orchestration, services, stacks, secrets

πŸ—‚οΈ Course Structure

learn-docker/
β”œβ”€β”€ 01-starting-with-docker/
β”‚   └── README.md                 # Introduction, installation, first container
β”œβ”€β”€ 02-docker-images/
β”‚   └── README.md                 # Images, registries, tagging
β”œβ”€β”€ 03-build-your-own-images/
β”‚   β”œβ”€β”€ README.md                 # Dockerfile guide
β”‚   └── examples/
β”‚       β”œβ”€β”€ 01-simple-nginx/      # Basic Nginx example
β”‚       β”œβ”€β”€ 02-python-app/        # Python Flask app
β”‚       β”œβ”€β”€ 03-nodejs-app/        # Node.js Express app
β”‚       β”œβ”€β”€ 04-multistage-go/     # Multi-stage Go build
β”‚       └── 06-cmd-entrypoint/    # CMD vs ENTRYPOINT
β”œβ”€β”€ 04-managing-containers/
β”‚   └── README.md                 # Container lifecycle
β”œβ”€β”€ 05-networking-with-docker/
β”‚   β”œβ”€β”€ README.md                 # Networking concepts
β”‚   └── examples/
β”‚       └── multi-service/        # Multi-network example
β”œβ”€β”€ 06-docker-compose/
β”‚   β”œβ”€β”€ README.md                 # Docker Compose guide
β”‚   └── examples/
β”‚       β”œβ”€β”€ basic-web/            # Simple web server
β”‚       β”œβ”€β”€ web-db/               # Web + database
β”‚       β”œβ”€β”€ full-stack/           # Complete application
β”‚       β”œβ”€β”€ scaling/              # Load balancing
β”‚       └── healthcheck/          # Health checks
β”œβ”€β”€ 07-docker-storage/
β”‚   β”œβ”€β”€ README.md                 # Storage and volumes guide
β”‚   └── examples/
β”‚       β”œβ”€β”€ backup-restore/       # Volume backup scripts
β”‚       β”œβ”€β”€ database-persistence/ # Persistent database
β”‚       β”œβ”€β”€ development-workflow/ # Bind mounts for dev
β”‚       └── shared-volumes/       # Shared data patterns
└── 08-docker-swarm/
    β”œβ”€β”€ README.md                 # Docker Swarm orchestration
    └── examples/
        β”œβ”€β”€ basic-service/        # Simple swarm service
        β”œβ”€β”€ web-stack/            # Multi-service stack
        β”œβ”€β”€ secrets-demo/         # Secrets management
        β”œβ”€β”€ rolling-updates/      # Zero-downtime updates
        β”œβ”€β”€ production-stack/     # Production-ready stack
        └── multi-node-simulation/ # Swarm cluster simulation

πŸš€ Getting Started

Prerequisites

  • A computer with at least 4GB RAM
  • Administrative/sudo access
  • Internet connection

Quick Start

  1. Clone this repository:

    git clone https://github.com/hatamiarash7/learn-docker.git
    cd learn-docker
  2. Install Docker:

  3. Verify installation:

    docker --version
    docker run hello-world
  4. Start learning:


πŸ“š Course Content

  • What is Docker and why use it?
  • Installing Docker on Linux, macOS, and Windows
  • Running your first container
  • Basic container commands
  • Understanding images and layers
  • Pulling and pushing images
  • Image registries (Docker Hub, private)
  • Tagging and versioning strategies
  • Saving and loading images for offline use
  • Dockerfile basics and instructions
  • Building images with docker build
  • Best practices for Dockerfiles
  • Multi-stage builds for smaller images
  • Multi-architecture builds
  • Health checks in Dockerfiles
  • Understanding CMD vs ENTRYPOINT
  • Container lifecycle (create, start, stop, remove)
  • Executing commands in containers
  • Viewing and managing logs
  • Resource limits (CPU, memory)
  • Container inspection and debugging
  • Docker networking fundamentals
  • Bridge, host, and none networks
  • Creating custom networks
  • Container DNS and service discovery
  • Port mapping strategies
  • Network isolation patterns
  • Container storage fundamentals
  • Docker volumes (named, anonymous)
  • Bind mounts for development
  • tmpfs mounts for sensitive data
  • Volume drivers and plugins
  • Backup and restore strategies
  • Data persistence patterns
  • Shared data between containers
  • Introduction to Docker Compose
  • Writing docker-compose.yml files
  • Defining services, networks, and volumes
  • Multi-container application patterns
  • Scaling services
  • Environment variables and secrets
  • Health checks and dependencies
  • Swarm mode architecture
  • Initializing and managing swarms
  • Services, replicas, and tasks
  • Stack deployments
  • Overlay networking
  • Secrets and configs management
  • Rolling updates and rollbacks
  • Scaling and load balancing
  • Health checks and placement constraints
  • Production best practices
  • Monitoring with Prometheus & Grafana

9. Final Project (Coming Soon)

...

πŸ’‘ Learning Tips

  1. Follow in order: Each section builds on previous knowledge
  2. Type commands yourself: Don't just copy-paste, understand each command
  3. Experiment: Try modifying examples and see what happens
  4. Clean up: Use docker system prune to free up disk space
  5. Read error messages: Docker's error messages are usually helpful

πŸ› οΈ Useful Commands Cheat Sheet

# Container Management
docker run <image>              # Run a container
docker ps                       # List running containers
docker ps -a                    # List all containers
docker stop <container>         # Stop a container
docker rm <container>           # Remove a container
docker logs <container>         # View container logs

# Image Management
docker images                   # List images
docker pull <image>             # Download an image
docker build -t <name> .        # Build an image
docker rmi <image>              # Remove an image

# Docker Compose
docker-compose up -d            # Start services
docker-compose down             # Stop services
docker-compose logs -f          # Follow logs
docker-compose ps               # List services

# Docker Swarm
docker swarm init               # Initialize swarm
docker node ls                  # List swarm nodes
docker service create           # Create a service
docker service ls               # List services
docker service scale <svc>=N    # Scale service
docker stack deploy -c file.yml # Deploy stack
docker stack rm <name>          # Remove stack
docker secret create            # Create secret

# System
docker system df                # Show disk usage
docker system prune             # Clean up resources

🎯 Exercises

Each section contains practical exercises marked with 🎯. Solutions are provided in collapsible sections.

Exercise Format:

  • Clear objectives
  • Step-by-step instructions
  • Expected outcomes
  • Hidden solutions (click to reveal)

πŸ“‚ Example Projects

Basic Examples

  • Simple Nginx - Static website with Nginx
  • Python Flask - Web API with Flask
  • Node.js Express - REST API with Express

Advanced Examples

  • Multi-stage Go - Optimized Go application
  • Full Stack - Nginx + API + Database + Cache
  • Scaling - Load balanced application
  • Health Checks - Proper dependency management
  • Volume Backup - Data backup and restore scripts
  • Production Swarm - Complete production stack with monitoring
  • Rolling Updates - Zero-downtime deployments

🀝 Contributing

Contributions are welcome! If you find errors or have suggestions:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Happy Learning! 🐳

Start your Docker journey with Section 1: Starting with Docker

About

A comprehensive, hands-on Docker learning course

Topics

Resources

License

Stars

Watchers

Forks

Contributors