# dharannuthan/docker-zero-to-hero architecture

> Architecture diagram of the GitHub repository dharannuthan/docker-zero-to-hero, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dharannuthan/docker-zero-to-hero
- Repository: https://github.com/dharannuthan/docker-zero-to-hero

## Overview

##### Project type and purpose
- This is an educational “zero-to-hero” Docker tutorial repository. It provides hands-on examples (Python app, Go multi-stage build, Python/Django web app) demonstrating how to write Dockerfiles, build images, run containers, and push to registries.
- It is not a monolithic full-stack application but rather a set of isolated example projects illustrating Docker concepts and patterns.

##### File structure
- Top-level:
- README.md, commands.md, networking.md, volumes.md – documentation and theory
- examples/ – a folder containing independent sample projects
- examples/first-docker-file: a minimal Python “Hello World” with a single-stage Dockerfile
- examples/golang-multi-stage-docker-build: Go app illustrating multi-stage vs. single-stage builds
- examples/python-web-app: Django-based web app, showing a more complex setup with SQLite, templates, migrations, and associated Dockerfile
- No microservices or multiple backends—each example is standalone

##### Key insights from the README
- Container basics (images, containers, lifecycle: build, run, push)
- Highlights Docker architecture: CLI ↔ daemon, registries, layers, namespaces, cgroups
- Encourages progression through examples, each teaching a new Docker feature

a. Main components to include:
- Developer workstation (IDE, source code + Docker CLI)
- Docker Engine (docker daemon + container runtime)
- Example project folders (first-docker-file, Go builds, python-web-app)
- Dockerfile parser & builder (build context, layers)
- Container images (intermediate and final)
- Containers at runtime
- Docker Hub (or other registry) for image push/pull
- Host resources: filesystem (volumes), network namespace

b. Relationships and interactions:
1. Developer edits code & Dockerfile → issues `docker build` (CLI → daemon).
2. Docker daemon reads build context, executes Dockerfile steps → produces layered image.
3. `docker run` → daemon instantiates container(s) from image, attaches network, volumes.
4. Container executes application (Python app, Go binary, Django server).
5. Optional: `docker push` / `docker pull` to/from Docker Hub.

c. Architectural patterns & design principles:
- Layered image architecture (each Dockerfile instruction = one layer)
- Multi-stage build pattern (build dependencies in one stage, copy only final binary into slimmer runtime stage)
- Separation of concerns: code vs. build instructions vs. runtime environment
- Isolation primitives: namespaces for network, PID; cgroups for resource limits; volumes for persistent data

d. Relevant technologies & frameworks:
- Docker Engine (dockerd) and Docker CLI
- Python3 & pip, Flask or simple Python script (first-docker-file)
- Go compiler, multi-stage Dockerfile (golang example)
- Django framework, SQLite, Django ORM/migrations (python-web-app)
- Underlying base images (ubuntu, golang, python)

##### Detailed capture of essential elements
- Example:
- first-docker-file: “WORKDIR /app → COPY → RUN apt-get … → CMD python3 app.py”
- golang-multi-stage: “Stage 1: golang:build → Stage 2: alpine:final (copy /app/calculator)”
- python-web-app: “Base python image → Pip install requirements.txt → Django server + SQLite file mounted”
- How volumes (`db.sqlite3`) and networks (default bridge) are attached to containers

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer Workstation
    subgraph "Developer Workstation"
        CLI["Docker CLI"]:::engine
        README["README.md"]:::code
        CMDS["commands.md"]:::code
        NET["networking.md"]:::code
        VOLS["volumes.md"]:::code
    end

    %% Examples Projects
    subgraph "Examples"
        subgraph "Python Hello World"
            PDockerfile["Dockerfile"]:::code
            PApp["app.py"]:::code
        end
        subgraph "Go Multi-stage Build"
            GMDockerfile["Dockerfile"]:::code
            GMGo["calculator.go"]:::code
            subgraph "Go Single-stage Variant"
                GSDockerfile["Dockerfile"]:::code
                GSGo["calculator.go"]:::code
            end
        end
        subgraph "Python Django Web App"
            WDockerfile["Dockerfile"]:::code
            WReq["requirements.txt"]:::code
            WManage["manage.py"]:::code
            WDB["db.sqlite3"]:::code
            WSettings["settings.py"]:::code
            WTemplate["demo_site.html"]:::code
        end
    end

    %% Docker Engine Core
    DockerDaemon["Docker Daemon"]:::engine
    Builder["Build Context & Parser"]:::engine
    DockerDaemon --> Builder
    CLI -->|"docker build"| DockerDaemon

    %% Feeding build context
    PDockerfile --> Builder
    PApp --> Builder
    GMDockerfile --> Builder
    GMGo --> Builder
    GSDockerfile --> Builder
    GSGo --> Builder
    WDockerfile --> Builder
    WReq --> Builder
    WManage --> Builder
    WDB --> Builder
    WSettings --> Builder
    WTemplate --> Builder

    %% Image and Container Flow
    Builder -->|"produce layers"| ImageLayers["Image Layers"]:::image
    ImageLayers -->|"instantiate"| Container["Container Instance"]:::image
    Container -->|"attach"| HostResources["Host Resources\n(Volumes, Network)"]:::resources

    %% Registry Interaction
    Container -->|"docker push/pull"| Registry["Docker Registry"]:::registry

    %% Click Events
    click README "https://github.com/dharannuthan/docker-zero-to-hero/blob/main/README.md"
    click CMDS "https://github.com/dharannuthan/docker-zero-to-hero/blob/main/commands.md"
    click NET "https://github.com/dharannuthan/docker-zero-to-hero/blob/main/networking.md"
    click VOLS "https://github.com/dharannuthan/docker-zero-to-hero/blob/main/volumes.md"

    click PDockerfile "https://github.com/dharannuthan/docker-zero-to-hero/tree/main/examples/first-docker-file/Dockerfile"
    click PApp "https://github.com/dharannuthan/docker-zero-to-hero/blob/main/examples/first-docker-file/app.py"

    click GMDockerfile "https://github.com/dharannuthan/docker-zero-to-hero/tree/main/examples/golang-multi-stage-docker-build/Dockerfile"
    click GMGo "https://github.com/dharannuthan/docker-zero-to-hero/blob/main/examples/golang-multi-stage-docker-build/calculator.go"
    click GSDockerfile "https://github.com/dharannuthan/docker-zero-to-hero/tree/main/examples/golang-multi-stage-docker-build/dockerfile-without-multistage/Dockerfile"
    click GSGo "https://github.com/dharannuthan/docker-zero-to-hero/blob/main/examples/golang-multi-stage-docker-build/dockerfile-without-multistage/calculator.go"

    click WDockerfile "https://github.com/dharannuthan/docker-zero-to-hero/tree/main/examples/python-web-app/Dockerfile"
    click WReq "https://github.com/dharannuthan/docker-zero-to-hero/blob/main/examples/python-web-app/requirements.txt"
    click WManage "https://github.com/dharannuthan/docker-zero-to-hero/blob/main/examples/python-web-app/devops/manage.py"
    click WDB "https://github.com/dharannuthan/docker-zero-to-hero/blob/main/examples/python-web-app/devops/db.sqlite3"
    click WSettings "https://github.com/dharannuthan/docker-zero-to-hero/blob/main/examples/python-web-app/devops/devops/settings.py"
    click WTemplate "https://github.com/dharannuthan/docker-zero-to-hero/blob/main/examples/python-web-app/devops/demo/templates/demo_site.html"

    %% Styles
    classDef code fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef engine fill:#90EE90,stroke:#333,stroke-width:1px;
    classDef image fill:#FFA500,stroke:#333,stroke-width:1px;
    classDef resources fill:#D3D3D3,stroke:#333,stroke-width:1px;
    classDef registry fill:#87CEEB,stroke:#333,stroke-width:1px;
```
