# microsoft/mssql-docker architecture

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

- Interactive diagram: https://gitdiagram.com/microsoft/mssql-docker
- Repository: https://github.com/microsoft/mssql-docker

## Overview

##### Project Type & Purpose
– Tooling/library repository providing Dockerfiles, Helm charts, samples, and CI configs to build & publish SQL Server container images and related artifacts.
– Not a monolithic application but a modular build/distribution pipeline plus deployment integrations (Helm, Rancher, monitoring).

##### Main Components
A. **Source Repository** (root): Holds Dockerfiles, scripts, charts, examples, docs.
B. **CI/CD Pipelines**: AppVeyor (windows builds), possible Linux build runners.
C. **Build Contexts**:
1. Linux Images
- core mssql-server-linux Dockerfile
- preview/Flavors (RHEL, CentOS, SLES, Ubuntu)
- mssql-tools (sqlcmd, bcp) Dockerfiles
- monitor (Telegraf config + Grafana dashboard JSON)
2. Windows Images
- Developer, Express, Core variants under windows/…
- PowerShell build scripts (build.ps1, start.ps1)
D. **Publish Destination**
– Docker Hub (microsoft/mssql-server, microsoft/mssql-tools)
E. **Consumers & Integrations**
1. **Users & DevOps** (local Docker Engine on Linux/Windows)
2. **Kubernetes Deployments**
- Sample Helm charts (statefulset, pvc, service)
- Rancher Helm Chart (chart.yaml, templates, values)
3. **Language Drivers**
- OSS‐drivers (php, python, node) examples showing how to connect
4. **Monitoring**
- Telegraf → InfluxDB/Grafana (dashboard.json)

##### Relationships & Data Flows
– **Source Repo** → triggers **CI Pipelines** → produces **Docker Images** → **Push** to Docker Hub
– **Users/Clusters** → **Pull** images → **Run** containers
– **Containers** expose SQL endpoints → **Clients** (sqlcmd, apps via drivers) connect
– **Monitor** containers via Telegraf (host agent) → send metrics → Grafana dashboards
– **Helm/Rancher Charts** package deployment topologies (StatefulSet + PVC + Service)

##### Architectural Patterns & Design Principles
– **Modular Build Contexts**: Separate Dockerfiles per OS/flavor
– **Infrastructure-as-Code**: Helm charts & scripts to recreate deployments
– **CI/CD**: Automated image builds & publish
– **Separation of Concerns**: Tool images (mssql-tools) decoupled from engine images

##### Essential Elements
– Component names: Source Repo, CI Server, Docker Hub, Docker Engine (Linux/Win), Kubernetes Cluster, Helm/Rancher, Telegraf, Grafana, Language Drivers
– Data flows: Build → Publish → Deploy → Connect → Monitor

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Source Repository
    SourceRepo["Source Repository (root)"]:::blue
    click SourceRepo "https://github.com/microsoft/mssql-docker/tree/master//"

    %% CI/CD Pipelines
    subgraph "Build & CI" 
        direction TB
        CI["CI/CD Server\n(AppVeyor)"]:::blue
        click CI "https://github.com/microsoft/mssql-docker/blob/master//appveyor.yml"
        
        subgraph "Linux Build Pipeline"
            direction TB
            LB_Core["Core SQL Server Image\nDockerfile"]:::blue
            click LB_Core "https://github.com/microsoft/mssql-docker/tree/master//linux/mssql-server-linux/Dockerfile"
            
            subgraph "Preview Flavors"
                direction TB
                PF_CentOS["CentOS Dockerfile"]:::blue
                click PF_CentOS "https://github.com/microsoft/mssql-docker/tree/master//linux/preview/CentOS/Dockerfile"
                PF_RHEL["RHEL Dockerfile"]:::blue
                click PF_RHEL "https://github.com/microsoft/mssql-docker/tree/master//linux/preview/RHEL/Dockerfile"
                PF_SLES["SLES Dockerfile"]:::blue
                click PF_SLES "https://github.com/microsoft/mssql-docker/tree/master//linux/preview/SLES/Dockerfile"
                PF_Ubuntu["Ubuntu Dockerfile"]:::blue
                click PF_Ubuntu "https://github.com/microsoft/mssql-docker/tree/master//linux/preview/Ubuntu/Dockerfile"
            end
            
            subgraph "mssql-tools Images"
                direction TB
                MT_Alpine["alpine Dockerfile"]:::blue
                click MT_Alpine "https://github.com/microsoft/mssql-docker/blob/master//linux/mssql-tools/Dockerfile.alpine"
                MT_Debian["debian11 Dockerfile"]:::blue
                click MT_Debian "https://github.com/microsoft/mssql-docker/blob/master//linux/mssql-tools/Dockerfile.debian11"
                MT_RHEL9["rhel9 Dockerfile"]:::blue
                click MT_RHEL9 "https://github.com/microsoft/mssql-docker/blob/master//linux/mssql-tools/Dockerfile.rhel9"
                MT_Ub2004["ubuntu2004 Dockerfile"]:::blue
                click MT_Ub2004 "https://github.com/microsoft/mssql-docker/blob/master//linux/mssql-tools/Dockerfile.ubuntu2004"
                MT_Ub2204["ubuntu2204 Dockerfile"]:::blue
                click MT_Ub2204 "https://github.com/microsoft/mssql-docker/blob/master//linux/mssql-tools/Dockerfile.ubuntu2204"
            end
            
            subgraph "Monitoring Context"
                direction TB
                Monitor_TF["telegraf.conf"]:::blue
                click Monitor_TF "https://github.com/microsoft/mssql-docker/blob/master//linux/monitor/telegraf.conf"
                Monitor_DB["dashboard.json"]:::blue
                click Monitor_DB "https://github.com/microsoft/mssql-docker/blob/master//linux/monitor/dashboard/dashboard.json"
            end
        end
        
        subgraph "Windows Build Pipeline"
            direction TB
            WB_PS["build.ps1"]:::blue
            click WB_PS "https://github.com/microsoft/mssql-docker/blob/master//windows/build.ps1"
            
            subgraph "SQL Server Variants"
                direction TB
                Win_Dev["Developer Dockerfile"]:::blue
                click Win_Dev "https://github.com/microsoft/mssql-docker/tree/master//windows/mssql-server-windows-developer/dockerfile"
                Win_DevStart["start.ps1"]:::blue
                click Win_DevStart "https://github.com/microsoft/mssql-docker/blob/master//windows/mssql-server-windows-developer/start.ps1"
                
                Win_Expr["Express Dockerfile"]:::blue
                click Win_Expr "https://github.com/microsoft/mssql-docker/tree/master//windows/mssql-server-windows-express/dockerfile"
                Win_ExprStart["start.ps1"]:::blue
                click Win_ExprStart "https://github.com/microsoft/mssql-docker/blob/master//windows/mssql-server-windows-express/start.ps1"
                
                Win_Core["Core Dockerfile"]:::blue
                click Win_Core "https://github.com/microsoft/mssql-docker/tree/master//windows/mssql-server-windows/dockerfile"
                Win_CoreStart["start.ps1"]:::blue
                click Win_CoreStart "https://github.com/microsoft/mssql-docker/blob/master//windows/mssql-server-windows/start.ps1"
            end
        end
    end

    %% Publish Destination
    DockerHub["Docker Hub"]:::gray

    %% Runtime Environments
    subgraph "Runtime & Deployment"
        direction TB
        Engines["Docker Engine\n(Linux & Windows)"]:::green
        Kubernetes["Kubernetes Cluster"]:::green
        
        subgraph "Helm & Rancher Charts"
            direction TB
            RancherChart["Rancher Chart"]:::green
            click RancherChart "https://github.com/microsoft/mssql-docker/blob/master//linux/rancher/Chart.yaml"
            click RancherChart "https://github.com/microsoft/mssql-docker/blob/master//linux/rancher/templates/statefulset.yaml"
            click RancherChart "https://github.com/microsoft/mssql-docker/blob/master//linux/rancher/templates/service.yaml"
            click RancherChart "https://github.com/microsoft/mssql-docker/blob/master//linux/rancher/values.yaml"
            
            SampleStateful["Sample StatefulSet Chart"]:::green
            click SampleStateful "https://github.com/microsoft/mssql-docker/blob/master//linux/sample-helm-chart-statefulset-deployment/Chart.yaml"
            click SampleStateful "https://github.com/microsoft/mssql-docker/blob/master//linux/sample-helm-chart-statefulset-deployment/templates/deployment.yaml"
            click SampleStateful "https://github.com/microsoft/mssql-docker/blob/master//linux/sample-helm-chart-statefulset-deployment/templates/service.yaml"
            click SampleStateful "https://github.com/microsoft/mssql-docker/blob/master//linux/sample-helm-chart-statefulset-deployment/values.yaml"
            
            SampleGeneric["Generic Sample Chart"]:::green
            click SampleGeneric "https://github.com/microsoft/mssql-docker/blob/master//linux/sample-helm-chart/Chart.yaml"
            click SampleGeneric "https://github.com/microsoft/mssql-docker/blob/master//linux/sample-helm-chart/templates/deployment.yaml"
            click SampleGeneric "https://github.com/microsoft/mssql-docker/blob/master//linux/sample-helm-chart/templates/service.yaml"
            click SampleGeneric "https://github.com/microsoft/mssql-docker/blob/master//linux/sample-helm-chart/values.yaml"
        end
        
        subgraph "Monitoring Backend"
            direction TB
            InfluxDB["InfluxDB"]:::gray
            Grafana["Grafana"]:::gray
        end
        
        subgraph "Clients & Drivers"
            direction TB
            SQLCmd["sqlcmd & bcp"]:::orange
            PHPDriver["PHP Driver"]:::orange
            click PHPDriver "https://github.com/microsoft/mssql-docker/tree/master//oss-drivers/msphpsql/Dockerfile"
            PHPMSSQL["php-mssql Driver"]:::orange
            click PHPMSSQL "https://github.com/microsoft/mssql-docker/tree/master//oss-drivers/php-mssql/Dockerfile"
            PythonODBC["Python ODBC"]:::orange
            click PythonODBC "https://github.com/microsoft/mssql-docker/tree/master//oss-drivers/pyodbc/Dockerfile"
            NodeTedious["Node.js (Tedious)"]:::orange
            click NodeTedious "https://github.com/microsoft/mssql-docker/tree/master//oss-drivers/tedious/Dockerfile"
        end
    end

    %% Connections: Build & Publish
    SourceRepo -->|"triggers build"| CI
    CI -->|"docker build (Linux)"| LB_Core
    CI -->|"docker build (Windows)"| Win_Dev
    CI -->|"docker push"| DockerHub

    %% Runtime flows
    DockerHub -->|"docker pull"| Engines
    Engines -->|"docker run"| Containers["SQL Server Containers"]:::green
    Containers -->|"sql connection"| SQLCmd
    Containers -->|"sql connection"| PHPDriver
    Containers -->|"sql connection"| PHPMSSQL
    Containers -->|"sql connection"| PythonODBC
    Containers -->|"sql connection"| NodeTedious

    Engines -->|"run monitoring sidecar"| MonitorAgent["Telegraf Agent"]:::orange
    MonitorAgent -->|"metrics"| InfluxDB
    InfluxDB -->|"visualize"| Grafana

    Engines -->|"deploy with Helm"| Kubernetes
    Kubernetes --> RancherChart
    Kubernetes --> SampleStateful
    Kubernetes --> SampleGeneric

    %% Styles
    classDef blue fill:#cce5ff,stroke:#000,stroke-width:1px
    classDef green fill:#d4edda,stroke:#000,stroke-width:1px
    classDef orange fill:#fff3cd,stroke:#000,stroke-width:1px
    classDef gray fill:#e2e3e5,stroke:#000,stroke-width:1px
```
