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

πŸ—‚οΈ 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

πŸš€ 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
  • 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

7. Storage / Volumes (Coming Soon)

...

8. Swarm Mode & Orchestration (Coming Soon)

...

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

# 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

🀝 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