# itspanand/docker-zero-to-hero architecture

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

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

## Overview

##### Project Type and Purpose
- This is an educational, example‐driven repository (“Docker Zero to Hero”) designed to teach Docker concepts through progressively complex hands‐on examples.

##### File Structure
- Root level:
- README.md, commands.md, networking.md, volumes.md – conceptual docs describing Docker concepts, CLI commands, networks and volumes.
- examples/ – contains three subfolders, each a self‐contained demo:
– first-docker-file/ (Python script + Dockerfile)
– golang-multi-stage-docker-build/ (Go code + multi‐stage Dockerfile + non‐multi‐stage example)
– python-web-app/ (Django app, SQLite DB, settings, templates, Dockerfile, requirements.txt)

##### README for Additional Insights
- Docker lifecycle: build → run → push
- Isolation primitives: namespaces, cgroups
- Emphasis on layering (each Dockerfile step → image layer)

a. Main Components
– Developer/CI (user invoking `docker build`, `docker run`, `docker push`)
– Docker Client (CLI)
– Docker Daemon (dockerd)
– Host OS Kernel & Filesystem
– Docker Engine & Storage (image layers, container writable layers)
– Docker Registry (Docker Hub or private registry)
– Containers running example workloads:
- Simple Python “app.py” container
- Go multi‐stage build compiled binary container
- Django web app container with SQLite volume
b. Relationships & Interactions
- Developer → Docker Client → Docker Daemon (API calls)
- Daemon ↔ Registry (pull/push images)
- Daemon → Storage Driver (builds image layers)
- Daemon → Host Kernel (namespaces, cgroups)
- Daemon → Containers (run, stop, network attach)
- Containers → Host Resources (network, volumes)
– Show multi‐stage build: build container producing binary → final runtime container
– Show volume mount for Django’s db.sqlite3
c. Architectural Patterns & Principles
– Client‐Server (CLI ↔ daemon)
– Layered immutable images + writable container layer
– Separation of build vs runtime (multi‐stage Dockerfile)
– Isolation via namespaces & cgroups
d. Key Technologies & Frameworks
– Docker (Engine, CLI, Registry)
– Python 3 and pip for simple app
– Go compiler for multi‐stage build
– Django framework + SQLite database for web app
– Linux kernel features (namespaces, cgroups, union‐fs drivers)

##### Detailed Capture of Architectural Elements
- Developer workstation or CI runner invoking commands.
- Docker internals: image layering, union‐fs driver, writable container layer.
- Inset callouts for example apps: code → Dockerfile → built image → running container → optional volume mount.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Global Entities
    Developer["Developer/CI Runner"]:::control
    DockerClient["Docker Client (CLI)"]:::control
    DockerDaemon["Docker Daemon (dockerd)"]:::control
    DockerRegistry["Docker Registry"]:::artifact
    StorageDriver["Storage Driver (union-fs)"]:::host
    HostKernel["Host OS Kernel"]:::host
    Namespaces["Namespaces & Cgroups"]:::host

    %% Developer to Client to Daemon
    Developer -->|"docker build/run/push"| DockerClient
    DockerClient -->|"API calls"| DockerDaemon

    %% Daemon interactions
    DockerDaemon -->|"build image layers"| StorageDriver
    DockerDaemon -->|"invoke kernel features"| HostKernel
    DockerDaemon -->|"apply isolation"| Namespaces
    DockerDaemon <-->|"push/pull images"| DockerRegistry

    %% Examples Subgraph
    subgraph "Example Workloads"
        direction TB

        subgraph "Simple Python App (first-stage build)"
            direction TB
            PyCode["app.py"]:::code
            PyDockerfile["Dockerfile"]:::code
            PyImage["Image: python-app"]:::artifact
            PyContainer["Container: app.py"]:::artifact

            PyCode --> PyDockerfile
            PyDockerfile -->|"docker build"| PyImage
            PyImage -->|"docker run"| PyContainer
        end

        subgraph "Go Multi-Stage Build"
            direction TB
            GoBuilderDocker["Dockerfile (multi-stage)"]:::code
            GoBuilderCode["calculator.go"]:::code
            GoBuilderImage["Image: builder"]:::artifact
            GoRuntimeImage["Image: go-app"]:::artifact
            GoContainer["Container: go-app"]:::artifact

            GoBuilderCode --> GoBuilderDocker
            GoBuilderDocker -->|"stage 1 build"| GoBuilderImage
            GoBuilderImage -->|"stage 2 copy & build"| GoRuntimeImage
            GoRuntimeImage -->|"docker run"| GoContainer
        end

        subgraph "Go Single-Stage Build"
            direction TB
            GoSingleDocker["Dockerfile (single-stage)"]:::code
            GoSingleCode["calculator.go"]:::code
            GoSingleImage["Image: go-app-single"]:::artifact
            GoSingleContainer["Container: go-app-single"]:::artifact

            GoSingleCode --> GoSingleDocker
            GoSingleDocker -->|"docker build"| GoSingleImage
            GoSingleImage -->|"docker run"| GoSingleContainer
        end

        subgraph "Django Web App"
            direction TB
            DjDockerfile["Dockerfile"]:::code
            DjRequirements["requirements.txt"]:::code
            DjManage["manage.py"]:::code
            DjSettings["devops/settings.py"]:::code
            DjUrls["devops/urls.py"]:::code
            DjWSGI["devops/wsgi.py"]:::code
            DjDemo["devops/demo/ (app & templates)"]:::code
            DjSQLite["db.sqlite3 (volume)"]:::artifact
            DjImage["Image: django-app"]:::artifact
            DjContainer["Container: django-app"]:::artifact

            DjManage & DjSettings & DjUrls & DjWSGI & DjDemo & DjRequirements --> DjDockerfile
            DjDockerfile -->|"docker build"| DjImage
            DjImage -->|"docker run with volume"| DjContainer
            DjContainer -->|"mount"| DjSQLite
        end
    end

    %% Click Events
    click Developer "https://github.com/itspanand/docker-zero-to-hero/blob/main/README.md"
    click DockerClient "https://github.com/itspanand/docker-zero-to-hero/blob/main/commands.md"
    click DockerDaemon "https://github.com/itspanand/docker-zero-to-hero/blob/main/networking.md"
    click DockerRegistry "https://github.com/itspanand/docker-zero-to-hero/blob/main/volumes.md"

    click PyDockerfile "https://github.com/itspanand/docker-zero-to-hero/tree/main/examples/first-docker-file/Dockerfile"
    click PyCode "https://github.com/itspanand/docker-zero-to-hero/blob/main/examples/first-docker-file/app.py"

    click GoBuilderDocker "https://github.com/itspanand/docker-zero-to-hero/tree/main/examples/golang-multi-stage-docker-build/Dockerfile"
    click GoBuilderCode "https://github.com/itspanand/docker-zero-to-hero/blob/main/examples/golang-multi-stage-docker-build/calculator.go"

    click GoSingleDocker "https://github.com/itspanand/docker-zero-to-hero/tree/main/examples/golang-multi-stage-docker-build/dockerfile-without-multistage/Dockerfile"
    click GoSingleCode "https://github.com/itspanand/docker-zero-to-hero/blob/main/examples/golang-multi-stage-docker-build/dockerfile-without-multistage/calculator.go"

    click DjDockerfile "https://github.com/itspanand/docker-zero-to-hero/tree/main/examples/python-web-app/Dockerfile"
    click DjRequirements "https://github.com/itspanand/docker-zero-to-hero/blob/main/examples/python-web-app/requirements.txt"
    click DjManage "https://github.com/itspanand/docker-zero-to-hero/blob/main/examples/python-web-app/devops/manage.py"
    click DjSettings "https://github.com/itspanand/docker-zero-to-hero/blob/main/examples/python-web-app/devops/devops/settings.py"
    click DjUrls "https://github.com/itspanand/docker-zero-to-hero/blob/main/examples/python-web-app/devops/devops/urls.py"
    click DjWSGI "https://github.com/itspanand/docker-zero-to-hero/blob/main/examples/python-web-app/devops/devops/wsgi.py"
    click DjDemo "https://github.com/itspanand/docker-zero-to-hero/tree/main/examples/python-web-app/devops/demo/"
    click DjSQLite "https://github.com/itspanand/docker-zero-to-hero/blob/main/examples/python-web-app/devops/db.sqlite3"

    %% Styles
    classDef control fill:#ACE,stroke:#000
    classDef artifact fill:#9f9,stroke:#000
    classDef host fill:#FC9,stroke:#000
    classDef code fill:#C9F,stroke:#000
```
