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.
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 |
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
- A computer with at least 4GB RAM
- Administrative/sudo access
- Internet connection
-
Clone this repository:
git clone https://github.com/hatamiarash7/learn-docker.git cd learn-docker -
Install Docker:
- Follow the instructions in 01-starting-with-docker
-
Verify installation:
docker --version docker run hello-world
-
Start learning:
- Begin with Section 1: Starting with Docker
- 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
...
...
...
- Follow in order: Each section builds on previous knowledge
- Type commands yourself: Don't just copy-paste, understand each command
- Experiment: Try modifying examples and see what happens
- Clean up: Use
docker system pruneto free up disk space - Read error messages: Docker's error messages are usually helpful
# 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 resourcesEach 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)
- Simple Nginx - Static website with Nginx
- Python Flask - Web API with Flask
- Node.js Express - REST API with Express
- Multi-stage Go - Optimized Go application
- Full Stack - Nginx + API + Database + Cache
- Scaling - Load balanced application
- Health Checks - Proper dependency management
Contributions are welcome! If you find errors or have suggestions:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
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