├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── SECURITY.md ├── appveyor.yml ├── linux ├── monitor │ ├── dashboard │ │ └── dashboard.json │ ├── readme.md │ └── telegraf.conf ├── mssql-server-linux │ └── Dockerfile ├── mssql-tools │ ├── Dockerfile.alpine │ ├── Dockerfile.debian11 │ ├── Dockerfile.rhel9 │ ├── Dockerfile.ubuntu2004 │ └── Dockerfile.ubuntu2204 ├── preview │ ├── CentOS │ │ ├── Dockerfile │ │ ├── Makefile │ │ └── uid_entrypoint │ ├── README.md │ ├── RHEL │ │ ├── Dockerfile │ │ ├── Makefile │ │ ├── licenses │ │ │ └── LICENSE │ │ └── uid_entrypoint │ ├── SLES │ │ ├── Dockerfile │ │ ├── README.md │ │ └── mssql.conf │ ├── Ubuntu │ │ └── Dockerfile │ ├── adutil │ │ └── adutil_pre_release_license.md │ ├── examples │ │ ├── mssql-agent-fts-ha-tools │ │ │ └── Dockerfile │ │ ├── mssql-cli │ │ │ └── Dockerfile │ │ ├── mssql-customize │ │ │ ├── Dockerfile │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── configure-db.sh │ │ │ ├── entrypoint.sh │ │ │ └── setup.sql │ │ ├── mssql-mlservices │ │ │ ├── ConfigureAndTestMLServices.ipynb │ │ │ ├── Dockerfile │ │ │ ├── README.md │ │ │ ├── build-container │ │ │ ├── run-container │ │ │ └── supervisord.conf │ │ ├── mssql-polybase-fts-tools │ │ │ └── Dockerfile │ │ ├── mssql-polybase │ │ │ ├── Dockerfile │ │ │ └── README.md │ │ ├── mssql-rhel7-sql2019 │ │ │ └── Dockerfile │ │ ├── mssql-rhel8-sql2017 │ │ │ └── Dockerfile │ │ └── mssql-server-linux-non-root │ │ │ ├── Dockerfile │ │ │ └── Dockerfile-2019 │ └── openSUSE │ │ ├── Dockerfile │ │ ├── README.md │ │ └── mssql.conf ├── rancher │ ├── .gitignore │ ├── Chart.yaml │ ├── Makefile │ ├── app-readme.md │ ├── questions.yml │ ├── readme.md │ ├── templates │ │ ├── _helpers.tpl │ │ ├── configmap.yaml │ │ ├── secret.yaml │ │ ├── service.yaml │ │ ├── statefulset.yaml │ │ └── storageclass.yaml │ ├── values.example.yaml │ ├── values.test.yaml │ └── values.yaml ├── sample-helm-chart-statefulset-deployment │ ├── .helmignore │ ├── Chart.yaml │ ├── readme.md │ ├── services │ │ ├── Ag_endpoint.yaml │ │ └── ex_service.yaml │ ├── templates │ │ ├── _helpers.tpl │ │ ├── deployment.yaml │ │ ├── mssqlconfig.yaml │ │ ├── sc.yaml │ │ └── service.yaml │ └── values.yaml └── sample-helm-chart │ ├── Chart.yaml │ ├── readme.md │ ├── templates │ ├── _helpers.tpl │ ├── deployment.yaml │ ├── mssqlconfig.yaml │ ├── pvc.yaml │ ├── secret.yaml │ └── service.yaml │ └── values.yaml ├── oss-drivers ├── msphpsql │ ├── Dockerfile │ ├── README.md │ ├── entrypoint.sh │ └── sample.php ├── php-mssql │ ├── Dockerfile │ ├── README.md │ └── connect.php ├── pyodbc │ ├── Dockerfile │ ├── README.md │ ├── entrypoint.sh │ └── sample.py └── tedious │ ├── Dockerfile │ ├── README.md │ ├── entrypoint.sh │ └── sample.js └── windows ├── README.md ├── build.ps1 ├── mssql-server-windows-developer ├── dockerfile ├── dockerfile_1 ├── readme.md └── start.ps1 ├── mssql-server-windows-express ├── dockerfile ├── readme.md └── start.ps1 └── mssql-server-windows ├── dockerfile ├── readme.md └── start.ps1 /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at opensource@microsoft.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright(c) 2016 Microsoft Corporation 2 | All rights reserved. 3 | 4 | MIT License 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), 6 | to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 13 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 14 | IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SQL Server in Docker 2 | 3 | This GitHub repository aims to provide a centralized location for community engagement. In here you will find documentation, Dockerfiles and additional developer resources. 4 | 5 | **SQL Server in Docker** comes in two different flavors: 6 | - [Linux-based containers](https://github.com/Microsoft/mssql-docker/tree/master/linux): This Docker image uses [SQL Server 2017 Developer Edition on Linux](https://docs.microsoft.com/en-us/sql/linux/) on top of an Ubuntu 16.04 base image. This is meant to be run on [Docker Engine](https://www.docker.com/products/overview) on its multiple platforms. There are also Dockerfiles here for building [RHEL](linux/preview/RHEL/Dockerfile) & [CentOS](linux/preview/CentOS/Dockerfile) based images. 7 | - [Windows-based containers](https://github.com/Microsoft/mssql-docker/tree/master/windows): These Docker images use SQL Server 2017 Express Edition and SQL Server 2017 Developer Edition. Both images are based on Windows Container technology and can only be run using [Docker Engine for Windows Containers](https://msdn.microsoft.com/en-us/virtualization/windowscontainers/docker/configure_docker_daemon). You can currently sign-up for SQL Server 2019 on Windows Containers available in our [Early Adopter Preview](https://cloudblogs.microsoft.com/sqlserver/2019/07/01/sql-server-2019-on-windows-containers-now-in-early-adopters-program/) program. 8 | 9 | Before choosing to run a SQL Server container for production use cases, please review our [support policy](https://support.microsoft.com/en-us/help/4047326/support-policy-for-microsoft-sql-server) for SQL Server Containers to ensure that you are running on a supported configuration. 10 | 11 | **SQL Server Command Line Tools(sqlcmd,bcp)** are also available as a Docker Image. You can now deliver SQL Server management payload using this as a base image for your CI/CD scenarios. Check out the [mssql-tools Docker Image](https://hub.docker.com/r/microsoft/mssql-tools/) to get started. 12 | 13 | 14 | Visit the [Microsoft Docker Hub page](https://hub.docker.com/u/microsoft) for more information and additional images. 15 | 16 | ## Documentation 17 | - [Getting started guide for the SQL Server on Linux container](https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker) 18 | - [Best practices guide](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-configure-docker) 19 | 20 | ## Take our survey 21 | 22 | Let us know more about how you would like to use SQL containers by taking our [survey](https://www.surveymonkey.com/r/XXSY536). 23 | 24 | ## Issues 25 | 26 | For any issues with the repo, please file under this GitHub project on the [Issues section](https://github.com/Microsoft/mssql-docker/issues). 27 | 28 | If you require support with a production related issue, then please raise a support incident with Microsoft [here](https://support.microsoft.com/en-us/hub/4343728/support-for-business). 29 | 30 | There is also a [Gitter channel for SQL Server in DevOps](https://gitter.im/Microsoft/mssql-devops?utm_source=share-link&utm_medium=link&utm_campaign=share-link) that you can join and discuss interesting topics with other container, SQL Server, and DevOps enthusiasts. 31 | 32 | ## Troubleshooting & Frequently Asked Questions 33 | 34 | - "Unknown blob" error code: You are probably trying to run the Windows Containers-based Docker image on a Linux-based Docker Engine. If you want to continue running the Windows Container-based image, we recommend reading the following community article: [Run Linux and Windows Containers on Windows 10](https://stefanscherer.github.io/run-linux-and-windows-containers-on-windows-10/). 35 | 36 | - When using the Windows Docker CLI you must use double quotes instead of single ticks for the environment variables, else the mssql-server-linux image won't find the `ACCEPT_EULA` or `SA_PASSWORD` variables which are required to start the container. 37 | 38 | - The 'sa' password has a minimum complexity requirement (8 characters, uppercase, lowercase, alphanumerical and/or non-alphanumerical) 39 | 40 | - Licensing for SQL Server in Docker: Regardless of where you run it - VM, Docker, physical, cloud, on prem - the licensing model is the same and it depends on which edition of SQL Server you are using. The Express and Developer Editions are free. Standard and Enterprise have a cost. More information here: [https://www.microsoft.com/en-us/sql-server/sql-server-2016-editions](https://www.microsoft.com/en-us/sql-server/sql-server-2016-editions) 41 | 42 | ## License 43 | 44 | The Docker resource files for SQL Server are licensed under the MIT license. See the [LICENSE file](LICENSE) for more details. 45 | 46 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | image: Windows Server 2016 2 | 3 | build_script: 4 | - ps: .\windows\build.ps1 5 | 6 | clone_depth: 1 7 | test: off 8 | deploy: off 9 | -------------------------------------------------------------------------------- /linux/monitor/readme.md: -------------------------------------------------------------------------------- 1 | This blog https://techcommunity.microsoft.com/t5/sql-server/near-real-time-monitoring-of-sql-server-linux-containers-using/ba-p/2620050 has the details you can review to setup near real time monitoring for SQL Server on Linux/Containers. We are going to setup the monitoring using the Telegraf-InfluxDB and Grafana. 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /linux/monitor/telegraf.conf: -------------------------------------------------------------------------------- 1 | # Global tags can be specified here in key="value" format. 2 | # [global_tags] 3 | # dc = "us-east-1" # will tag all metrics with dc=us-east-1 4 | # rack = "1a" 5 | # Environment variables can be used as tags, and throughout the config file 6 | # user = "$USER" 7 | 8 | # Configuration for telegraf agent 9 | [agent] 10 | # Default data collection interval for all inputs 11 | interval = "15s" 12 | 13 | 14 | # Read metrics from SQL Server 15 | # Various sections for each Database Type. 16 | 17 | 18 | #[[inputs.sqlserver]] 19 | #interval = "15s" 20 | #Setting Database to Managed Instance. 21 | #database_type = "AzureSQLDB" 22 | 23 | #List of Servers to Collect Data from 24 | #servers = ["Server=YOURSERVER.database.windows.net;User Id=telegraf;Password=MyComplexPassword1!;database=YOURDB;app name=telegraf;connection timeout = 5"] 25 | 26 | 27 | ## database_type = AzureSQLDB by default collects the following queries 28 | ## - AzureSQLDBWaitStats 29 | ## - AzureSQLDBResourceStats 30 | ## - AzureSQLDBResourceGovernance 31 | ## - AzureSQLDBDatabaseIO 32 | ## - AzureSQLDBServerProperties 33 | ## - AzureSQLDBOsWaitstats 34 | ## - AzureSQLDBMemoryClerks 35 | ## - AzureSQLDBPerformanceCounters 36 | ## - AzureSQLDBRequests 37 | ## - AzureSQLDBSchedulers 38 | 39 | #exclude_query = [ 'AzureSQLDBSchedulers' , 'AzureSQLDBSqlRequests'] 40 | 41 | 42 | 43 | #[[inputs.sqlserver]] 44 | #interval = "15s" 45 | #Setting Database to Managed Instance. 46 | 47 | #database_type = "AzureSQLManagedInstance" 48 | #servers = ["Server=YOURSERVER.database.windows.net;Port=1433;User Id=telegraf;Password=MyComplexPassword1!;app name=telegraf;connection timeout = 5"] 49 | 50 | #List of Servers to Collect Data from 51 | ## Possible collectors for database_type = AzureSQLManagedInstance by default collects the following queries 52 | ## - AzureSQLMIResourceStats 53 | ## - AzureSQLMIResourceGovernance 54 | ## - AzureSQLMIDatabaseIO 55 | ## - AzureSQLMIServerProperties 56 | ## - AzureSQLMIOsWaitstats 57 | ## - AzureSQLMIMemoryClerks 58 | ## - AzureSQLMIPerformanceCounters 59 | ## - AzureSQLMIRequests 60 | ## - AzureSQLMISchedulers 61 | 62 | #exclude_query = [ 'AzureSQLMISchedulers' , 'AzureSQLMISqlRequests'] 63 | 64 | 65 | 66 | [[inputs.sqlserver]] 67 | interval = "15s" 68 | #Setting Database to Managed Instance. 69 | database_type = "SQLServer" 70 | 71 | #List of Servers to Collect Data from 72 | servers = ["Server=10.0.0.19;Port=5433;User Id=telegraf;Password=MyComplexPassword1!;app name=telegraf;connection timeout = 5","Server=10.0.0.19;Port=1433;User Id=telegraf;Password=MyComplexPassword1!;app name=telegraf;connection timeout = 5","Server=10.0.0.20;Port=1433;User Id=telegraf;Password=MyComplexPassword1!;app name=telegraf;connection timeout = 5"] 73 | 74 | 75 | ## database_type = SQLServer by default collects the following queries 76 | ## - SQLServerPerformanceCounters 77 | ## - SQLServerWaitStatsCategorized 78 | ## - SQLServerDatabaseIO 79 | ## - SQLServerProperties 80 | ## - SQLServerMemoryClerks 81 | ## - SQLServerSchedulers 82 | ## - SQLServerRequests 83 | ## - SQLServerVolumeSpace 84 | ## - SQLServerCpu 85 | 86 | exclude_query = [ 'SQLServerRequests' , 'SQLServerSchedulers'] 87 | 88 | 89 | 90 | #Change the influxDB settings to point to your InfluxDB install 91 | #[[outputs.influxdb_v2]] 92 | ## The URLs of the InfluxDB cluster nodes. 93 | ## 94 | ## Multiple URLs can be specified for a single cluster, only ONE of the 95 | ## urls will be written to each interval. 96 | ## urls exp: http://127.0.0.1:8086 97 | #urls = ["http://influxdb:8086"] 98 | 99 | ## Token for authentication. 100 | # token = "DPc148KA6E79yRKmID6lKbeh-9jpEcUqRoAKFUdmlsEIemy7HGAKlCL3Bq3I6anzfHP7rIWQIFo9DniQzoz8TQ==" 101 | 102 | ## Organization is the name of the organization you wish to write to; must exist. 103 | # organization = "sqlmonitor" 104 | 105 | ## Destination bucket to write into. 106 | # bucket = "sqlbucket" 107 | [[outputs.influxdb]] 108 | database = "telegraf" 109 | urls = ["http://10.0.0.22:8086"] 110 | 111 | # if you want sparate databases, use namepass which will direct output metrics to specific databases 112 | #[[outputs.influxdb]] 113 | # database = "mssql_metrics" 114 | # urls = ["http://localhost:8086"] 115 | # namepass = ["sqlserver*"] 116 | 117 | #[[outputs.influxdb]] 118 | # database = "docker_metrics" 119 | # urls = ["http://localhost:8086"] 120 | # namepass = ["*_docker"] 121 | 122 | -------------------------------------------------------------------------------- /linux/mssql-server-linux/Dockerfile: -------------------------------------------------------------------------------- 1 | # mssql-server-linux 2 | # Maintainers: Microsoft Corporation (LuisBosquez and twright-msft on GitHub) 3 | # GitRepo: https://github.com/Microsoft/mssql-docker 4 | 5 | # Base OS layer: Latest Ubuntu LTS. 6 | FROM ubuntu:16.04 7 | 8 | # Default SQL Server TCP/Port. 9 | EXPOSE 1433 10 | 11 | # Copy all SQL Server runtime files from build drop into image. 12 | COPY ./install / 13 | 14 | # Run SQL Server process. 15 | CMD [ "/opt/mssql/bin/sqlservr" ] 16 | -------------------------------------------------------------------------------- /linux/mssql-tools/Dockerfile.alpine: -------------------------------------------------------------------------------- 1 | # SQL Server Command Line Tools 2 | FROM alpine 3 | 4 | LABEL maintainer="SQL Server Engineering Team" 5 | 6 | RUN apk add curl gnupg 7 | 8 | #Download the desired package(s) 9 | RUN curl -O https://download.microsoft.com/download/b/9/f/b9f3cce4-3925-46d4-9f46-da08869c6486/msodbcsql18_18.0.1.1-1_amd64.apk \ 10 | && curl -O https://download.microsoft.com/download/b/9/f/b9f3cce4-3925-46d4-9f46-da08869c6486/mssql-tools18_18.0.1.1-1_amd64.apk 11 | 12 | 13 | #(Optional) Verify signature, if 'gpg' is missing install it using 'apk add gnupg': 14 | RUN curl -O https://download.microsoft.com/download/b/9/f/b9f3cce4-3925-46d4-9f46-da08869c6486/msodbcsql18_18.0.1.1-1_amd64.sig \ 15 | && curl -O https://download.microsoft.com/download/b/9/f/b9f3cce4-3925-46d4-9f46-da08869c6486/mssql-tools18_18.0.1.1-1_amd64.sig 16 | 17 | RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --import - \ 18 | && gpg --verify msodbcsql18_18.0.1.1-1_amd64.sig msodbcsql18_18.0.1.1-1_amd64.apk \ 19 | && gpg --verify mssql-tools18_18.0.1.1-1_amd64.sig mssql-tools18_18.0.1.1-1_amd64.apk 20 | 21 | 22 | #Install the package(s) 23 | RUN apk add --allow-untrusted msodbcsql18_18.0.1.1-1_amd64.apk \ 24 | && apk add --allow-untrusted mssql-tools18_18.0.1.1-1_amd64.apk \ 25 | && rm -f msodbcsql18_18.0.1.1-1_amd64.apk mssql-tools18_18.0.1.1-1_amd64.apk 26 | 27 | 28 | CMD /bin/bash 29 | -------------------------------------------------------------------------------- /linux/mssql-tools/Dockerfile.debian11: -------------------------------------------------------------------------------- 1 | # SQL Server Command Line Tools 2 | FROM debian:11 3 | 4 | LABEL maintainer="SQL Server Engineering Team" 5 | 6 | # apt-get and system utilities 7 | RUN apt-get update && apt-get install -y \ 8 | curl apt-transport-https debconf-utils gnupg2 9 | 10 | # adding custom MS repository 11 | RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - 12 | RUN curl https://packages.microsoft.com/config/debian/11/prod.list > /etc/apt/sources.list.d/mssql-release.list 13 | 14 | # install SQL Server drivers and tools 15 | RUN apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 16 | RUN echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc 17 | RUN /bin/bash -c "source ~/.bashrc" 18 | 19 | 20 | 21 | RUN apt-get -y install locales \ 22 | && rm -rf /var/lib/apt/lists/* 23 | RUN locale-gen en_US.UTF-8 24 | RUN localedef -i en_US -f UTF-8 en_US.UTF-8 25 | 26 | 27 | CMD /bin/bash 28 | -------------------------------------------------------------------------------- /linux/mssql-tools/Dockerfile.rhel9: -------------------------------------------------------------------------------- 1 | # SQL Server Command Line Tools 2 | FROM redhat/ubi9 3 | 4 | LABEL maintainer="SQL Server Engineering Team" 5 | 6 | # adding custom MS repository 7 | RUN yum install -y https://packages.microsoft.com/config/rhel/9.0/packages-microsoft-prod.rpm 8 | 9 | # install SQL Server drivers and tools 10 | RUN ACCEPT_EULA=Y dnf install -y msodbcsql18 mssql-tools18 11 | 12 | # add the binary location to the $PATH 13 | RUN echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc 14 | RUN /bin/bash -c "source ~/.bashrc" 15 | 16 | CMD /bin/bash 17 | -------------------------------------------------------------------------------- /linux/mssql-tools/Dockerfile.ubuntu2004: -------------------------------------------------------------------------------- 1 | # SQL Server Command Line Tools 2 | FROM ubuntu:20.04 3 | 4 | LABEL maintainer="SQL Server Engineering Team" 5 | 6 | # apt-get and system utilities 7 | RUN apt-get update && apt-get install -y \ 8 | curl apt-transport-https debconf-utils gnupg2 9 | 10 | # adding custom MS repository 11 | RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - 12 | RUN curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list 13 | 14 | # install SQL Server drivers and tools 15 | RUN apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 16 | RUN echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc 17 | RUN /bin/bash -c "source ~/.bashrc" 18 | 19 | 20 | 21 | RUN apt-get -y install locales \ 22 | && rm -rf /var/lib/apt/lists/* 23 | RUN locale-gen en_US.UTF-8 24 | RUN update-locale LANG=en_US.UTF-8 25 | 26 | 27 | 28 | CMD /bin/bash 29 | -------------------------------------------------------------------------------- /linux/mssql-tools/Dockerfile.ubuntu2204: -------------------------------------------------------------------------------- 1 | # SQL Server Command Line Tools 2 | FROM ubuntu:22.04 3 | 4 | LABEL maintainer="SQL Server Engineering Team" 5 | 6 | # apt-get and system utilities 7 | RUN apt-get update && apt-get install -y \ 8 | curl apt-transport-https debconf-utils gnupg2 9 | 10 | # adding custom MS repository 11 | RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - 12 | RUN curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list > /etc/apt/sources.list.d/mssql-release.list 13 | 14 | # install SQL Server drivers and tools 15 | RUN apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 16 | RUN echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc 17 | RUN /bin/bash -c "source ~/.bashrc" 18 | 19 | 20 | 21 | RUN apt-get -y install locales \ 22 | && rm -rf /var/lib/apt/lists/* 23 | RUN locale-gen en_US.UTF-8 24 | RUN update-locale LANG=en_US.UTF-8 25 | 26 | 27 | 28 | CMD /bin/bash 29 | -------------------------------------------------------------------------------- /linux/preview/CentOS/Dockerfile: -------------------------------------------------------------------------------- 1 | # mssql-server-rhel 2 | # Maintainers: Travis Wright (twright-msft on GitHub) 3 | # GitRepo: https://github.com/twright-msft/mssql-server-rhel 4 | 5 | # Base OS layer: latest CentOS 7 6 | FROM centos:7 7 | 8 | ### Atomic/OpenShift Labels - https://github.com/projectatomic/ContainerApplicationGenericLabels 9 | LABEL name="microsoft/mssql-server-linux" \ 10 | vendor="Microsoft" \ 11 | version="14.0" \ 12 | release="1" \ 13 | summary="MS SQL Server" \ 14 | description="MS SQL Server is ....." \ 15 | ### Required labels above - recommended below 16 | url="https://www.microsoft.com/en-us/sql-server/" \ 17 | run='docker run --name ${NAME} \ 18 | -e ACCEPT_EULA=Y -e SA_PASSWORD=yourStrong@Password \ 19 | -p 1433:1433 \ 20 | -d ${IMAGE}' \ 21 | io.k8s.description="MS SQL Server is ....." \ 22 | io.k8s.display-name="MS SQL Server" 23 | 24 | # Install latest mssql-server package 25 | RUN curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo && \ 26 | curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo && \ 27 | ACCEPT_EULA=Y yum install -y mssql-server mssql-tools unixODBC-devel && \ 28 | yum clean all 29 | 30 | COPY uid_entrypoint /opt/mssql-tools/bin/ 31 | ENV PATH=${PATH}:/opt/mssql/bin:/opt/mssql-tools/bin 32 | RUN mkdir -p /var/opt/mssql/data && \ 33 | chmod -R g=u /var/opt/mssql /etc/passwd 34 | 35 | ### Containers should not run as root as a good practice 36 | USER 10001 37 | 38 | # Default SQL Server TCP/Port 39 | EXPOSE 1433 40 | 41 | VOLUME /var/opt/mssql/data 42 | 43 | ### user name recognition at runtime w/ an arbitrary uid - for OpenShift deployments 44 | ENTRYPOINT [ "uid_entrypoint" ] 45 | # Run SQL Server process 46 | CMD sqlservr 47 | -------------------------------------------------------------------------------- /linux/preview/CentOS/Makefile: -------------------------------------------------------------------------------- 1 | CONTEXT = microsoft 2 | VERSION = v14.0 3 | IMAGE_NAME = mssql-server-linux 4 | TARGET = centos7 5 | REGISTRY = docker-registry.default.svc.cluster.local 6 | OC_USER = developer 7 | OC_PASS = developer 8 | SA_PASSWORD = yourStrong@Password 9 | 10 | all: build 11 | build: 12 | docker build --pull -t ${CONTEXT}/${IMAGE_NAME}:${TARGET}-${VERSION} -t ${CONTEXT}/${IMAGE_NAME} . 13 | @if docker images ${CONTEXT}/${IMAGE_NAME}:${TARGET}-${VERSION}; then touch build; fi 14 | 15 | lint: 16 | dockerfile_lint -f Dockerfile 17 | 18 | test: 19 | $(eval CONTAINERID=$(shell docker run -e ACCEPT_EULA=Y -e SA_PASSWORD=${SA_PASSWORD} -d ${CONTEXT}/${IMAGE_NAME}:${TARGET}-${VERSION})) 20 | @sleep 2 21 | @docker exec ${CONTAINERID} ps aux 22 | @sleep 20 23 | @docker exec ${CONTAINERID} sqlcmd -S localhost -U SA -P ${SA_PASSWORD} -Q "sp_databases" 24 | @docker rm -f ${CONTAINERID} 25 | 26 | run: 27 | docker run -e ACCEPT_EULA=Y -e SA_PASSWORD=${SA_PASSWORD} -p 1433:1433 -d ${CONTEXT}/${IMAGE_NAME}:${TARGET}-${VERSION} 28 | 29 | clean: 30 | rm -f build -------------------------------------------------------------------------------- /linux/preview/CentOS/uid_entrypoint: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if ! whoami &> /dev/null; then 3 | if [ -w /etc/passwd ]; then 4 | echo "${USER_NAME:-sqlservr}:x:$(id -u):0:${USER_NAME:-sqlservr} user:${HOME}:/sbin/nologin" >> /etc/passwd 5 | fi 6 | fi 7 | exec "$@" 8 | -------------------------------------------------------------------------------- /linux/preview/README.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | There are five Linux-based Docker container images documented here: 3 | * A representation of the actual [Dockerfile](Ubuntu/Dockerfile) that is used by Microsoft to build the Ubuntu-based image [mssql-server-linux](https://hub.docker.com/_/microsoft-mssql-server) which is available at Docker Hub. 4 | * A [Dockerfile](CentOS/Dockerfile) for building a CentOS-based image on your own 5 | * A [Dockerfile](RHEL/Dockerfile) for building a RHEL-based image on your own 6 | * A [Dockerfile](SLES/dockerfile) for building a SLES-based image on your own 7 | * A [Dockerfile](openSUSE/dockerfile) for building an openSUSE-based image on your own 8 | 9 | Full documentation can be found at the [SQL Server on Linux Docker image page](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-docker). 10 | 11 | Learn more about the latest release of SQL Server on Linux here: [SQL Server on Linux Documentation](https://docs.microsoft.com/en-us/sql/linux/). 12 | 13 | # mssql-server-linux 14 | 15 | This Ubuntu-based image is built and maintened by Microsoft, and published on [Docker Hub](https://hub.docker.com/_/microsoft-mssql-server). 16 | 17 | # mssql-server-centos 18 | 19 | ## To build a CentOS-based image 20 | To build an image locally on your Docker host follow these steps: 21 | ```shell 22 | $ cd linux/preview/CentOS 23 | $ make 24 | $ make test 25 | $ make run 26 | ``` 27 | 28 | # mssql-server-rhel 29 | There is a [Dockerfile](RHEL/Dockerfile) on this project published for those that would like to build their own image based on the [official Red Hat Enterprise Linux 7 image](https://access.redhat.com/containers/#/registry.access.redhat.com/rhel7/rhel). 30 | 31 | ## Prerequisites for building a RHEL-based image 32 | * You will need access to the [Red Hat Container Catalog](https://access.redhat.com/containers) via a Red Hat subscription. 33 | * You will need to login to the Red Hat Container Catalog using docker login. [More info](https://access.redhat.com/articles/2834301) 34 | * You will also need to provide your Red Hat subscription credentials in the Dockerfile before you build. 35 | * You will also need to build the image yourself using Docker's command line tool '[docker](https://docs.docker.com/engine/reference/commandline/cli/)'. 36 | 37 | ## To build a RHEL-based image 38 | To build an image locally on your Docker host follow these steps: 39 | ```shell 40 | $ cd linux/preview/RHEL 41 | $ make 42 | $ make test 43 | $ make run 44 | ``` 45 | 46 | # Requirements 47 | --- 48 | - This image requires Docker Engine 1.8+ in any of [their supported platforms](https://www.docker.com/products/overview). 49 | - At least 3.25 GB of RAM. Make sure to assign enough memory to the Docker VM if you're running on Docker for [Mac](https://docs.docker.com/docker-for-mac/#/general) or [Windows](https://docs.docker.com/docker-for-windows/#/advanced). 50 | - Requires the following environment flags 51 | - ACCEPT_EULA=Y 52 | - SA_PASSWORD= 53 | - A strong system administrator (SA) password: At least 8 characters including uppercase, lowercase letters, base-10 digits and/or non-alphanumeric symbols. 54 | 55 | # How to use this image 56 | --- 57 | ## Start a mssql-server instance 58 | > ``docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -d microsoft/mssql-server-linux`` 59 | 60 | ## Connect to Microsoft SQL Server 61 | Starting with the CTP 1.4 (March 17, 2017) release the mssql-tools package including sqlcmd, bcp are included in the image. You can connect to the SQL Server using the sqlcmd tool inside of the container by using the following command on the host: 62 | ``` 63 | docker exec -it /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 64 | ``` 65 | You can also use the tools in an entrypoint.sh script to do things like create databases or logins, attach databases, import data, or other setup tasks. See this example of [using an entrypoint.sh script to create a database and schema and bcp in some data](https://github.com/twright-msft/mssql-node-docker-demo-app). 66 | 67 | You can connect to the SQL Server instance in the container from outside the container by using various command line and GUI tools on the host or remote computers. See the [Connect and Query](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-connect-and-query-sqlcmd) topic in the SQL Server on Linux documentation. 68 | 69 | ## Environment variables 70 | 71 | - ACCEPT_EULA confirms acceptance of the [End-User Licensing Agreement](http://go.microsoft.com/fwlink/?LinkId=746388). 72 | - SA_PASSWORD is the database system administrator (userid = 'sa') password used to connect to SQL Server once the container is running. 73 | 74 | Additional, optional environment variables are documented in the [product documentation](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-configure-environment-variables). 75 | 76 | 77 | # Current limitations 78 | --- 79 | - Mapping volumes to the host using 'docker run -v' is not supported for Docker for Mac. You can use [data volume containers](https://docs.docker.com/engine/tutorials/dockervolumes/#/creating-and-mounting-a-data-volume-container) instead for data file persistence. Resolving this limitation is tracked as issue [#12](https://github.com/Microsoft/mssql-docker/issues/12). 80 | 81 | # Feedback 82 | --- 83 | + For issues with or questions about these images or SQL Server on containers in general, please contact us through a [GitHub issue](https://github.com/Microsoft/mssql-docker/issues). 84 | + This is not an official support channel. If you require support with SQL Server, please contact Microsoft Support through the standard channels. 85 | 86 | # Frequently asked questions 87 | --- 88 | - **How do I map a volume using Docker for Windows?** Make sure to enable [shared drives in the settings menu](https://docs.docker.com/docker-for-windows/#shared-drives). After that, you can map a volume specifying the **Windows path:Linux path**. The following is an example of a command to map a Windows folder to the data directory in the container: 89 | 90 | > ``docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -v C:\MyWindowsVolume:/var/opt/mssql -d microsoft/mssql-server-linux`` 91 | 92 | # Further reading 93 | --- 94 | + [SQL Server on Linux for Docker documentation](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-docker) 95 | + [SQL Server - Developer Getting Started Tutorials](https://www.microsoft.com/en-us/sql-server/developer-get-started/?utm_source=DockerHub) 96 | 97 | # Additional Microsoft SQL Server Docker images 98 | + Latest *Pre-Release* Version of SQL Server *Evaluation* Edition for Windows Containers: [microsoft/mssql-server-windows](https://hub.docker.com/r/microsoft/mssql-server-windows/) 99 | + Latest *Released* Version of SQL Server *Developer* Edition for Windows Containers: [microsoft/mssql-server-windows-developer](https://hub.docker.com/r/microsoft/mssql-server-windows-developer/) 100 | + Latest *Released Version* of SQL Server *Express* Edition for Windows Containers: [microsoft/mssql-server-windows-express](https://hub.docker.com/r/microsoft/mssql-server-windows-express/) 101 | 102 | **Note:** Developer Edition is a full-featured version of SQL Server without resource limits, but can only be used in dev/test. Express Edition is a resource-limited edition of SQL Server that can be used in production. 103 | Get more information on [SQL Server Editions](https://www.microsoft.com/en-us/sql-server/sql-server-editions). 104 | -------------------------------------------------------------------------------- /linux/preview/RHEL/Dockerfile: -------------------------------------------------------------------------------- 1 | # mssql-server-rhel 2 | # Maintainers: Travis Wright (twright-msft on GitHub) 3 | # GitRepo: https://github.com/twright-msft/mssql-server-rhel 4 | 5 | # Base OS layer: latest RHEL 7 6 | FROM registry.access.redhat.com/rhel7 7 | 8 | ### Atomic/OpenShift Labels - https://github.com/projectatomic/ContainerApplicationGenericLabels 9 | LABEL name="microsoft/mssql-server-linux" \ 10 | vendor="Microsoft" \ 11 | version="14.0" \ 12 | release="1" \ 13 | summary="MS SQL Server" \ 14 | description="MS SQL Server is ....." \ 15 | ### Required labels above - recommended below 16 | url="https://www.microsoft.com/en-us/sql-server/" \ 17 | run='docker run --name ${NAME} \ 18 | -e ACCEPT_EULA=Y -e SA_PASSWORD=yourStrong@Password \ 19 | -p 1433:1433 \ 20 | -d ${IMAGE}' \ 21 | io.k8s.description="MS SQL Server is ....." \ 22 | io.k8s.display-name="MS SQL Server" 23 | 24 | ### add licenses to this directory 25 | COPY licenses /licenses 26 | 27 | # Install latest mssql-server package 28 | RUN REPOLIST=rhel-7-server-rpms,packages-microsoft-com-mssql-server-2017,packages-microsoft-com-prod && \ 29 | curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo && \ 30 | curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo && \ 31 | ACCEPT_EULA=Y yum -y install --disablerepo "*" --enablerepo ${REPOLIST} --setopt=tsflags=nodocs \ 32 | mssql-server mssql-tools unixODBC-devel && \ 33 | yum clean all 34 | 35 | COPY uid_entrypoint /opt/mssql-tools/bin/ 36 | ENV PATH=${PATH}:/opt/mssql/bin:/opt/mssql-tools/bin 37 | RUN mkdir -p /var/opt/mssql/data && \ 38 | chmod -R g=u /var/opt/mssql /etc/passwd 39 | 40 | ### Containers should not run as root as a good practice 41 | USER 10001 42 | 43 | # Default SQL Server TCP/Port 44 | EXPOSE 1433 45 | 46 | VOLUME /var/opt/mssql/data 47 | 48 | ### user name recognition at runtime w/ an arbitrary uid - for OpenShift deployments 49 | ENTRYPOINT [ "uid_entrypoint" ] 50 | # Run SQL Server process 51 | CMD sqlservr 52 | -------------------------------------------------------------------------------- /linux/preview/RHEL/Makefile: -------------------------------------------------------------------------------- 1 | CONTEXT = microsoft 2 | VERSION = v14.0 3 | IMAGE_NAME = mssql-server-linux 4 | TARGET = rhel7 5 | REGISTRY = docker-registry.default.svc.cluster.local 6 | OC_USER = developer 7 | OC_PASS = developer 8 | SA_PASSWORD = yourStrong@Password 9 | 10 | all: build 11 | build: 12 | docker build --pull -t ${CONTEXT}/${IMAGE_NAME}:${TARGET}-${VERSION} -t ${CONTEXT}/${IMAGE_NAME} . 13 | @if docker images ${CONTEXT}/${IMAGE_NAME}:${TARGET}-${VERSION}; then touch build; fi 14 | 15 | lint: 16 | dockerfile_lint -f Dockerfile 17 | 18 | test: 19 | $(eval CONTAINERID=$(shell docker run -e ACCEPT_EULA=Y -e SA_PASSWORD=${SA_PASSWORD} -d ${CONTEXT}/${IMAGE_NAME}:${TARGET}-${VERSION})) 20 | @sleep 2 21 | @docker exec ${CONTAINERID} ps aux 22 | @sleep 20 23 | @docker exec ${CONTAINERID} sqlcmd -S localhost -U SA -P ${SA_PASSWORD} -Q "sp_databases" 24 | @docker rm -f ${CONTAINERID} 25 | 26 | run: 27 | docker run -e ACCEPT_EULA=Y -e SA_PASSWORD=${SA_PASSWORD} -p 1433:1433 -d ${CONTEXT}/${IMAGE_NAME}:${TARGET}-${VERSION} 28 | 29 | clean: 30 | rm -f build -------------------------------------------------------------------------------- /linux/preview/RHEL/licenses/LICENSE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/mssql-docker/d7e572d6c8b761ec855c9337a08e0d88b0a5002a/linux/preview/RHEL/licenses/LICENSE -------------------------------------------------------------------------------- /linux/preview/RHEL/uid_entrypoint: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if ! whoami &> /dev/null; then 3 | if [ -w /etc/passwd ]; then 4 | echo "${USER_NAME:-sqlservr}:x:$(id -u):0:${USER_NAME:-sqlservr} user:${HOME}:/sbin/nologin" >> /etc/passwd 5 | fi 6 | fi 7 | exec "$@" 8 | -------------------------------------------------------------------------------- /linux/preview/SLES/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # Note: This image requires an active SLES15 subscription to build. 3 | # 4 | # Thank you to our SUSE Partners for helping with this :) 5 | # 6 | # Assumptions 7 | # 1. use a matching version to the underlying build host 8 | # 2. ensure it is registered to have access to needed repos 9 | # then leveraging container-suseconnect-zypp 10 | # e.g. zypper ref 11 | # Repository 'SLE-Module-Containers12-Pool' is up to date. 12 | # Repository 'SLE-Module-Containers12-Updates' is up to date. 13 | # Repository 'SLES12-SP5-Pool' is up to date. 14 | # Repository 'SLES12-SP5-Updates' is up to date. 15 | # All repositories have been refreshed. 16 | # 3. minimize the layers by consolidating commands 17 | 18 | FROM registry.suse.com/suse/sle15:15.3 19 | 20 | ENV ADDITIONAL_MODULES=sle-module-legacy 21 | 22 | RUN zypper install --no-confirm --no-recommends \ 23 | # install setcap to be used later 24 | # curl is needed for rpm import 25 | libcap-progs curl && \ 26 | rpm --import https://packages.microsoft.com/keys/microsoft.asc && \ 27 | zypper rm --no-confirm --clean-deps curl 28 | 29 | # consider merging the two RUNs to save ~ 40mb at the cost of caching adding the signing key 30 | 31 | # add mssql-server repo 32 | RUN zypper addrepo --no-check https://packages.microsoft.com/config/sles/15/mssql-server-2019.repo && \ 33 | zypper refresh packages-microsoft-com-mssql-server-2019 && \ 34 | # install mssql-server 35 | zypper install --no-confirm --auto-agree-with-licenses --no-recommends mssql-server && \ 36 | # add mssql-tools repo 37 | zypper addrepo --check https://packages.microsoft.com/config/sles/15/prod.repo && \ 38 | zypper refresh packages-microsoft-com-prod && \ 39 | # install mssql-tools (consider removing to reduce size) Microsoft already maintains a separate mssql-tools image 40 | ACCEPT_EULA=Y zypper install --no-confirm --no-recommends mssql-tools && \ 41 | zypper clean --all && \ 42 | # post installation of SQL Server the mssql user/group is created 43 | # so set the right permissions to the msssql folder 44 | mkdir -p -m 770 /var/opt/mssql && \ 45 | chown -R mssql /var/opt/mssql && \ 46 | # grant sql the permissions to connect to ports <1024 as a non-root user 47 | setcap 'cap_net_bind_service+ep' /opt/mssql/bin/sqlservr && \ 48 | # allow dumps from the non-root process 49 | setcap 'cap_sys_ptrace+ep' /opt/mssql/bin/paldumper && \ 50 | setcap 'cap_sys_ptrace+ep' /usr/bin/gdb && \ 51 | # ldconfig file because setcap causes the os to remove LD_LIBRARY_PATH 52 | # and other env variables that control dynamic linking 53 | mkdir -p /etc/ld.so.conf.d && \ 54 | touch /etc/ld.so.conf.d/mssql.conf && \ 55 | echo -e "# mssql libs\n/opt/mssql/lib" >> /etc/ld.so.conf.d/mssql.conf && \ 56 | ldconfig 57 | 58 | EXPOSE 1433 59 | 60 | USER mssql 61 | 62 | CMD ["/opt/mssql/bin/sqlservr"] 63 | -------------------------------------------------------------------------------- /linux/preview/SLES/README.md: -------------------------------------------------------------------------------- 1 | # How to build a SQL Server on SLES container image 2 | 3 | 1. Ensure that host machine is running the same version of the SLES that you will build SQL Server 2019 container image, in this case we are using a host which is running SLES15 SP3 and building the SQL Server also on top of SLES15 SP3. 4 | 5 | 2. Please ensure the host machine is registered using the SUSEConnect command as documented here: https://www.suse.com/support/kb/doc/?id=000018564 6 | 7 | 3. You can verify that the host machine is registered using a command shown below, the output you should see the status as registered and other details like the regcode. 8 | ``` 9 | SUSEConnect -s 10 | ``` 11 | 12 | 4. Depending on how your host machine is registered, setup your machine for SUSE [container-suseconnect](https://github.com/SUSE/container-suseconnect) correctly so the credentials can be made available to the container. Instructions differ for [RMT/SMT](https://github.com/SUSE/container-suseconnect#building-images-on-sle-systems-registered-with-rmt-or-smt), [on-demand/PAYG in the cloud](https://github.com/SUSE/container-suseconnect#building-images-on-demand-sle-instances-in-the-public-cloud), and [non SLES distros](https://github.com/SUSE/container-suseconnect#building-images-on-non-sle-distributions). 13 | 14 | **Steps to building SQL Server on SLES container image** 15 | 16 | 1. Create the dockerfile as shown in the dockerfile command and save it into your working directory 17 | 18 | 2. [optional] Customize the mssql.conf file. Example mssql.conf entries can be found here: https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-configure-mssql-conf?view=sql-server-2017#mssql-conf-format 19 | 20 | 3. Build the docker image. 21 | 22 | when host is registered against RMT/SMT 23 | ``` 24 | docker build . -t mssql-sles-tools-nonroot 25 | ``` 26 | when host is on-demand or payg in the public cloud 27 | ``` 28 | docker build --network host -t mssql-sles-tools-nonroot . 29 | ``` 30 | when using non SLES distros (Note: building on non SLES distros will require [additonal changes](https://github.com/SUSE/container-suseconnect#building-images-on-non-sle-distributions) to the Dockerfile) 31 | ``` 32 | docker build -t mssql-sles-tools-nonroot \ 33 | --secret id=SUSEConnect,src=SUSEConnect \ 34 | --secret id=SCCcredentials,src=SCCcredentials . 35 | ``` 36 | 37 | 4. Confirm the image is successfully created using the command 38 | ``` 39 | docker images 40 | ``` 41 | 4. Run the docker image. 42 | ``` 43 | sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=' \ 44 | -p 1433:1433 --name sql1 \ 45 | -d mssql-sles-tools-nonroot 46 | ``` 47 | -------------------------------------------------------------------------------- /linux/preview/SLES/mssql.conf: -------------------------------------------------------------------------------- 1 | [example] 2 | var = value -------------------------------------------------------------------------------- /linux/preview/Ubuntu/Dockerfile: -------------------------------------------------------------------------------- 1 | # mssql-server-linux 2 | # Maintainers: Microsoft Corporation (LuisBosquez and twright-msft on GitHub) 3 | # GitRepo: https://github.com/Microsoft/mssql-docker 4 | 5 | # Base OS layer: Latest Ubuntu LTS. 6 | FROM ubuntu:16.04 7 | 8 | # Default SQL Server TCP/Port. 9 | EXPOSE 1433 10 | 11 | # Copy all SQL Server runtime files from build drop into image. 12 | COPY ./install / 13 | 14 | # Run SQL Server process. 15 | CMD /opt/mssql/bin/sqlservr 16 | -------------------------------------------------------------------------------- /linux/preview/adutil/adutil_pre_release_license.md: -------------------------------------------------------------------------------- 1 | # MICROSOFT SOFTWARE LICENSE TERMS 2 | # MICROSOFT ADUTIL 3 | 4 | **IF YOU LIVE IN (OR ARE A BUSINESS WITH A PRINCIPAL PLACE OF BUSINESS 5 | IN) THE UNITED STATES, PLEASE READ THE "BINDING ARBITRATION AND CLASS 6 | ACTION WAIVER" SECTION BELOW. IT AFFECTS HOW DISPUTES ARE RESOLVED.** 7 | 8 | These license terms are an agreement between you and Microsoft 9 | Corporation (or one of its affiliates). They apply to the software named 10 | above and any Microsoft services or software updates (except to the 11 | extent such services or updates are accompanied by new or additional 12 | terms, in which case those different terms apply prospectively and do 13 | not alter your or Microsoft's rights relating to pre-updated software or 14 | services). IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE RIGHTS 15 | BELOW. BY USING THE SOFTWARE, YOU ACCEPT THESE TERMS. 16 | 17 | 1. **INSTALLATION AND USE RIGHTS.** 18 | 19 | a) **General.** You may install and use any number of copies of the software on your devices. You may not use the software in a live operating environment unless Microsoft permits you to do so under another agreement. 20 | 21 | b) **Third Party Components.** The software may include third party components with separate legal notices or governed by other agreements, as may be described in the ThirdPartyNotices file(s) accompanying the software. 22 | 23 | 2. **TIME-SENSITIVE SOFTWARE**. This agreement is effective on your acceptance and terminates on the earlier of (i) 30 days following first availability of a commercial release of the software or (ii) upon termination by Microsoft. Microsoft may extend this agreement in its discretion. 24 | 25 | 3. **SCOPE OF LICENSE.** The software is licensed, not sold. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you will not (and have no right to): 26 | 27 | a) work around any technical limitations in the software that only allow you to use it in certain ways; 28 | 29 | b) reverse engineer, decompile or disassemble the software, or otherwise attempt to derive the source code for the software, except and to the extent required by third party licensing terms governing use of certain open source components that may be included in the software; 30 | 31 | c) remove, minimize, block, or modify any notices of Microsoft or its suppliers in the software; 32 | 33 | d) use the software for commercial, non-profit, or revenue-generating activities; 34 | 35 | e) use the software in any way that is against the law or to create or propagate malware; or 36 | 37 | f) share, publish, distribute, or lease the software, provide the software as a stand-alone offering for others to use, or transfer the software or this agreement to any third party. 38 | 39 | 4. **PRE-RELEASE SOFTWARE.** The software is a pre-release version. It may not operate correctly. It may be different from the commercially released version. 40 | 41 | 5. **FEEDBACK.** If you give feedback about the software to Microsoft, you give to Microsoft, without charge, the right to use, share and commercialize your feedback in any way and for any purpose. You will not give feedback that is subject to a license that requires Microsoft to license its software or documentation to third parties because Microsoft includes your feedback in them. These rights survive this agreement. 42 | 43 | 6. **DATA.** This software may interact with other Microsoft products that collect data that is transmitted to Microsoft. To learn more about how Microsoft processes personal data we collect, please see the Microsoft Privacy Statement at . 44 | 45 | 7. **EXPORT RESTRICTIONS.** You must comply with all domestic and international export laws and regulations that apply to the software, which include restrictions on destinations, end users, and end use. For further information on export restrictions, visit . 46 | 47 | 8. **SUPPORT SERVICES.** Microsoft is not obligated under this agreement to provide any support services for the software. Any support provided is "as is", "with all faults", and without warranty of any kind. 48 | 49 | 9. **BINDING ARBITRATION AND CLASS ACTION WAIVER. This Section applies if you live in (or, if a business, your principal place of business is in) the United States.** If you and Microsoft have a dispute, you and Microsoft agree to try for 60 days to resolve it informally. If you and Microsoft can't, you and Microsoft **agree to binding individual arbitration before the American Arbitration Association under the Federal Arbitration Act ("FAA"), and not to sue in court in front of a judge or jury**. Instead, a neutral arbitrator will decide. **Class action lawsuits, class-wide arbitrations, private attorney-general actions, and any other proceeding where someone acts in a representative capacity are not allowed; nor is combining individual proceedings without the consent of all parties.** The complete Arbitration Agreement contains more terms and is at . You and Microsoft agree to these terms. 50 | 51 | 10. **TERMINATION.** Without prejudice to any other rights, Microsoft may terminate this agreement if you fail to comply with any of its terms or conditions. In such event, you must destroy all copies of the software and all of its component parts. 52 | 53 | 11. **ENTIRE AGREEMENT.** This agreement, and any other terms Microsoft may provide for supplements, updates, or third-party applications, is the entire agreement for the software. 54 | 55 | 12. **APPLICABLE LAW AND PLACE TO RESOLVE DISPUTES.** If you acquired the software in the United States or Canada, the laws of the state or province where you live (or, if a business, where your principal place of business is located) govern the interpretation of this agreement, claims for its breach, and all other claims (including consumer protection, unfair competition, and tort claims), regardless of conflict of laws principles, except that the FAA governs everything related to arbitration. If you acquired the software in any other country, its laws apply, except that the FAA governs everything related to arbitration. If U.S. federal jurisdiction exists, you and Microsoft consent to exclusive jurisdiction and venue in the federal court in King County, Washington for all disputes heard in court (excluding arbitration). If not, you and Microsoft consent to exclusive jurisdiction and venue in the Superior Court of King County, Washington for all disputes heard in court (excluding arbitration). 56 | 57 | 13. **CONSUMER RIGHTS; REGIONAL VARIATIONS.** This agreement describes certain legal rights. You may have other rights, including consumer rights, under the laws of your state, province, or country. Separate and apart from your relationship with Microsoft, you may also have rights with respect to the party from which you acquired the software. This agreement does not change those other rights if the laws of your state, province, or country do not permit it to do so. For example, if you acquired the software in one of the below regions, or mandatory country law applies, then the following provisions apply to you: 58 | 59 | a) **Australia.** You have statutory guarantees under the Australian Consumer Law and nothing in this agreement is intended to affect those rights. 60 | 61 | b) **Canada.** If you acquired this software in Canada, you may stop receiving updates by turning off the automatic update feature, disconnecting your device from the Internet (if and when you re-connect to the Internet, however, the software will resume checking for and installing updates), or uninstalling the software. The product documentation, if any, may also specify how to turn off updates for your specific device or software. 62 | 63 | c) **Germany and Austria**. 64 | 65 | i. Warranty. The properly licensed software will perform 66 | substantially as described in any Microsoft materials that accompany 67 | the software. However, Microsoft gives no contractual guarantee in 68 | relation to the licensed software. 69 | 70 | ii. Limitation of Liability. In case of intentional conduct, gross 71 | negligence, claims based on the Product Liability Act, as well as, in 72 | case of death or personal or physical injury, Microsoft is liable 73 | according to the statutory law. 74 | 75 | Subject to the foregoing clause ii., Microsoft will only be liable for slight negligence if Microsoft is in breach of such material contractual obligations, the fulfillment of which facilitate the due performance of this agreement, the breach of which would endanger the purpose of this agreement and the compliance with which a party may constantly trust in (so-called \"cardinal obligations\"). In other cases of slight negligence, Microsoft will not be liable for slight negligence. 76 | 77 | 14. **DISCLAIMER OF WARRANTY**. **THE SOFTWARE IS LICENSED "AS IS." YOU BEAR THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES, OR CONDITIONS. TO THE EXTENT PERMITTED UNDER APPLICABLE LAWS, MICROSOFT EXCLUDES ALL IMPLIED WARRANTIES, INCLUDING MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.** 78 | 79 | 15. **LIMITATION ON AND EXCLUSION OF DAMAGES**. **IF YOU HAVE ANY BASIS FOR RECOVERING DAMAGES DESPITE THE PRECEDING DISCLAIMER OF WARRANTY, YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. \$5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES.** 80 | 81 | > This limitation applies to (a) anything related to the software, 82 | > services, content (including code) on third party Internet sites, or 83 | > third party applications; and (b) claims for breach of contract, 84 | > warranty, guarantee, or condition; strict liability, negligence, or 85 | > other tort; or any other claim; in each case to the extent permitted 86 | > by applicable law. 87 | > 88 | > It also applies even if Microsoft knew or should have known about the 89 | > possibility of the damages. The above limitation or exclusion may not 90 | > apply to you because your state, province, or country may not allow 91 | > the exclusion or limitation of incidental, consequential, or other 92 | > damages. 93 | 94 | Please note: As this software is distributed in Canada, some of the 95 | clauses in this agreement are provided below in French. 96 | 97 | Remarque: Ce logiciel étant distribué au Canada, certaines des clauses 98 | dans ce contrat sont fournies ci-dessous en français. 99 | 100 | EXONÉRATION DE GARANTIE. Le logiciel visé par une licence est offert « 101 | tel quel ». Toute utilisation de ce logiciel est à votre seule risque et 102 | péril. Microsoft n'accorde aucune autre garantie expresse. Vous pouvez 103 | bénéficier de droits additionnels en vertu du droit local sur la 104 | protection des consommateurs, que ce contrat ne peut modifier. La ou 105 | elles sont permises par le droit locale, les garanties implicites de 106 | qualité marchande, d'adéquation à un usage particulier et d'absence de 107 | contrefaçon sont exclues. 108 | 109 | LIMITATION DES DOMMAGES-INTÉRÊTS ET EXCLUSION DE RESPONSABILITÉ POUR LES 110 | DOMMAGES. Vous pouvez obtenir de Microsoft et de ses fournisseurs une 111 | indemnisation en cas de dommages directs uniquement à hauteur de 5,00 \$ 112 | US. Vous ne pouvez prétendre à aucune indemnisation pour les autres 113 | dommages, y compris les dommages spéciaux, indirects ou accessoires et 114 | pertes de bénéfices. 115 | 116 | Cette limitation concerne: 117 | 118 | * tout ce qui est relié au logiciel, aux services ou au contenu (y 119 | compris le code) figurant sur des sites Internet tiers ou dans des 120 | programmes tiers; et 121 | 122 | * les réclamations au titre de violation de contrat ou de garantie, ou 123 | au titre de responsabilité stricte, de négligence ou d'une autre faute 124 | dans la limite autorisée par la loi en vigueur. 125 | 126 | Elle s'applique également, même si Microsoft connaissait ou devrait 127 | connaître l'éventualité d'un tel dommage. Si votre pays n'autorise pas 128 | l'exclusion ou la limitation de responsabilité pour les dommages 129 | indirects, accessoires ou de quelque nature que ce soit, il se peut que 130 | la limitation ou l'exclusion ci-dessus ne s'appliquera pas à votre 131 | égard. 132 | 133 | EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. 134 | Vous pourriez avoir d'autres droits prévus par les lois de votre pays. 135 | Le présent contrat ne modifie pas les droits que vous confèrent les lois 136 | de votre pays si celles-ci ne le permettent pas. 137 | -------------------------------------------------------------------------------- /linux/preview/examples/mssql-agent-fts-ha-tools/Dockerfile: -------------------------------------------------------------------------------- 1 | # mssql-agent-fts-ha-tools 2 | # Maintainers: Microsoft Corporation (twright-msft on GitHub) 3 | # GitRepo: https://github.com/Microsoft/mssql-docker 4 | 5 | # Base OS layer: Latest Ubuntu LTS 6 | FROM ubuntu:16.04 7 | 8 | # Install prerequistes since it is needed to get repo config for SQL server 9 | RUN export DEBIAN_FRONTEND=noninteractive && \ 10 | apt-get update && \ 11 | apt-get install -yq curl apt-transport-https && \ 12 | # Get official Microsoft repository configuration 13 | curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \ 14 | curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list | tee /etc/apt/sources.list.d/mssql-server.list && \ 15 | apt-get update && \ 16 | # Install SQL Server from apt 17 | apt-get install -y mssql-server && \ 18 | # Install optional packages 19 | apt-get install -y mssql-server-ha && \ 20 | apt-get install -y mssql-server-fts && \ 21 | # Cleanup the Dockerfile 22 | apt-get clean && \ 23 | rm -rf /var/lib/apt/lists 24 | 25 | # Run SQL Server process 26 | CMD /opt/mssql/bin/sqlservr 27 | -------------------------------------------------------------------------------- /linux/preview/examples/mssql-cli/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | 3 | # apt-get update and install required utilities 4 | RUN apt-get update && apt-get install -y \ 5 | curl apt-utils apt-transport-https debconf-utils gcc build-essential g++-5\ 6 | && rm -rf /var/lib/apt/lists/* 7 | 8 | # adding custom MS repository 9 | RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - 10 | RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list 11 | 12 | # Update the list of products 13 | RUN apt-get update 14 | 15 | # Install mssql-cli 16 | RUN apt-get install mssql-cli -y 17 | 18 | CMD ["/bin/bash", "-c", "sleep infinity"] -------------------------------------------------------------------------------- /linux/preview/examples/mssql-customize/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/mssql/server:2017-latest 2 | 3 | # Create a config directory 4 | RUN mkdir -p /usr/config 5 | WORKDIR /usr/config 6 | 7 | # Bundle config source 8 | COPY . /usr/config 9 | 10 | # Grant permissions for to our scripts to be executable 11 | RUN chmod +x /usr/config/entrypoint.sh 12 | RUN chmod +x /usr/config/configure-db.sh 13 | 14 | ENTRYPOINT ["./entrypoint.sh"] 15 | -------------------------------------------------------------------------------- /linux/preview/examples/mssql-customize/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Travis Wright 4 | Extensively modified work Copyright (c) 2017 Morgan Kobeissi and Vin Yu 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /linux/preview/examples/mssql-customize/README.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | * Build a docker image based on mcr.microsoft.com/mssql/server 4 | * Configure the `setup.sql` with the T-SQL you want to run after SQL Server has started. 5 | 6 | # How to Run 7 | ## Clone this repo 8 | ``` 9 | git clone https://github.com/microsoft/mssql-docker.git 10 | ``` 11 | 12 | ## Modify the setup.sql file 13 | 14 | modify the `mssql-docker/linux/preview/examples/mssql-customize/setup.sql` file with the TSQL that you want to customize the SQL Server container with. 15 | 16 | ## Build the image 17 | Build with `docker build`: 18 | ``` 19 | cd mssql-docker/linux/preview/examples/mssql-customize 20 | docker build -t mssql-custom . 21 | ``` 22 | 23 | ## Run the container 24 | 25 | Then spin up a new container using `docker run` 26 | ``` 27 | docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=StrongPassw0rd' -p 1433:1433 --name sql1 -d mssql-custom 28 | ``` 29 | 30 | Note: MSSQL passwords must be at least 8 characters long, contain upper case, lower case and digits. 31 | -------------------------------------------------------------------------------- /linux/preview/examples/mssql-customize/configure-db.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Wait 60 seconds for SQL Server to start up by ensuring that 4 | # calling SQLCMD does not return an error code, which will ensure that sqlcmd is accessible 5 | # and that system and user databases return "0" which means all databases are in an "online" state 6 | # https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-databases-transact-sql?view=sql-server-2017 7 | 8 | DBSTATUS=1 9 | ERRCODE=1 10 | i=0 11 | 12 | while [[ $DBSTATUS -ne 0 ]] && [[ $i -lt 60 ]] && [[ $ERRCODE -ne 0 ]]; do 13 | i=$i+1 14 | DBSTATUS=$(/opt/mssql-tools/bin/sqlcmd -h -1 -t 1 -U sa -P $SA_PASSWORD -Q "SET NOCOUNT ON; Select SUM(state) from sys.databases") 15 | ERRCODE=$? 16 | sleep 1 17 | done 18 | 19 | if [ $DBSTATUS -ne 0 ] OR [ $ERRCODE -ne 0 ]; then 20 | echo "SQL Server took more than 60 seconds to start up or one or more databases are not in an ONLINE state" 21 | exit 1 22 | fi 23 | 24 | # Run the setup script to create the DB and the schema in the DB 25 | /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $SA_PASSWORD -d master -i setup.sql 26 | 27 | -------------------------------------------------------------------------------- /linux/preview/examples/mssql-customize/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Start the script to create the DB and user 4 | /usr/config/configure-db.sh & 5 | 6 | # Start SQL Server 7 | /opt/mssql/bin/sqlservr 8 | 9 | 10 | -------------------------------------------------------------------------------- /linux/preview/examples/mssql-customize/setup.sql: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Enter custom T-SQL here that would run after SQL Server has started up. 4 | 5 | */ 6 | 7 | CREATE DATABASE HelloWorld; 8 | GO 9 | -------------------------------------------------------------------------------- /linux/preview/examples/mssql-mlservices/ConfigureAndTestMLServices.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | } 12 | }, 13 | "nbformat_minor": 2, 14 | "nbformat": 4, 15 | "cells": [ 16 | { 17 | "cell_type": "markdown", 18 | "source": "Connect to SQL Server and then run this T-SQL to enable external script execution:", 19 | "metadata": {} 20 | }, 21 | { 22 | "cell_type": "code", 23 | "source": "EXEC sp_configure 'external scripts enabled', 1\r\nRECONFIGURE WITH OVERRIDE", 24 | "metadata": {}, 25 | "outputs": [], 26 | "execution_count": 0 27 | }, 28 | { 29 | "cell_type": "markdown", 30 | "source": "Verify ML Services is working by running the following simple R/Python sp_execute_external_scripts:", 31 | "metadata": {} 32 | }, 33 | { 34 | "cell_type": "code", 35 | "source": "EXECUTE sp_execute_external_script \r\n@language = N'R',\r\n@script = N'\r\nprint(\"Hello World!\")\r\nprint(R.version)\r\nprint(Revo.version)\r\nOutputDataSet <- InputDataSet', \r\n@input_data_1 = N'select 1'\r\nGO", 36 | "metadata": {}, 37 | "outputs": [], 38 | "execution_count": 0 39 | }, 40 | { 41 | "cell_type": "code", 42 | "source": "EXECUTE sp_execute_external_script \r\n@language = N'Python',\r\n@script = N'\r\nimport sys\r\nprint(sys.version)\r\nprint(\"Hello World!\")\r\nOutputDataSet = InputDataSet',\r\n@input_data_1 = N'select 1'\r\nGO", 43 | "metadata": {}, 44 | "outputs": [], 45 | "execution_count": 0 46 | } 47 | ] 48 | } -------------------------------------------------------------------------------- /linux/preview/examples/mssql-mlservices/Dockerfile: -------------------------------------------------------------------------------- 1 | # Maintainers: Microsoft Corporation 2 | FROM ubuntu:18.04 3 | 4 | # copy in supervisord conf file 5 | COPY ./supervisord.conf /usr/local/etc/supervisord.conf 6 | 7 | # install supporting packages 8 | RUN apt-get update && \ 9 | apt-get install -y apt-transport-https \ 10 | curl \ 11 | supervisor \ 12 | fakechroot \ 13 | locales \ 14 | iptables \ 15 | sudo \ 16 | wget \ 17 | curl \ 18 | zip \ 19 | unzip \ 20 | make \ 21 | bzip2 \ 22 | m4 \ 23 | apt-transport-https \ 24 | tzdata \ 25 | libnuma-dev \ 26 | libsss-nss-idmap-dev \ 27 | software-properties-common 28 | 29 | # Adding custom MS repository 30 | RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - 31 | RUN curl https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2019.list > /etc/apt/sources.list.d/mssql-server-2019.list 32 | 33 | # install SQL Server ML services R and Python packages which will also install the mssql-server pacakge, the package for SQL Server itself 34 | # if you want to install only Python or only R, you can add/remove the package as needed below 35 | RUN apt-get update && \ 36 | apt-get install -y mssql-mlservices-packages-r \ 37 | mssql-mlservices-packages-py && \ 38 | # Cleanup the Dockerfile 39 | apt-get clean && \ 40 | rm -rf /var/apt/cache/* /tmp/* /var/tmp/* /var/lib/apt/lists 41 | 42 | 43 | # run checkinstallextensibility.sh 44 | RUN /opt/mssql/bin/checkinstallextensibility.sh && \ 45 | # set/fix directory permissions and create default directories 46 | chown -R root:root /opt/mssql/bin/launchpadd && \ 47 | chown -R root:root /opt/mssql/bin/setnetbr && \ 48 | mkdir -p /var/opt/mssql-extensibility/data && \ 49 | mkdir -p /var/opt/mssql-extensibility/log && \ 50 | chown -R root:root /var/opt/mssql-extensibility && \ 51 | chmod -R 777 /var/opt/mssql-extensibility && \ 52 | # locale-gen 53 | locale-gen en_US.UTF-8 54 | 55 | # expose SQL Server port 56 | EXPOSE 1433 57 | 58 | # start services with supervisord 59 | CMD /usr/bin/supervisord -n -c /usr/local/etc/supervisord.conf 60 | -------------------------------------------------------------------------------- /linux/preview/examples/mssql-mlservices/README.md: -------------------------------------------------------------------------------- 1 | SQL Server container images do not include Machine Learning Services to keep the image size down for typical use cases of SQL Server. This Dockerfile provides an example of how to build a container image that does include ML Services. 2 | This sample includes Machine Learning Services including R and python - the resulting image is about 9GB. 3 | 4 | # Usage 5 | 6 | ## Build 7 | 1. Git clone or download all these files and maintain the directory structure. 8 | 2. In the same directory as this readme file, run the following command 9 | ``` 10 | docker build -t mssql-server-mlservices . 11 | ``` 12 | > **Note:** 13 | > mssql-server-mlservices is just a suggested name for the container image. You can use a different name if you want to. 14 | 15 | > **Note:** 16 | > The Dockerfile does not install the mssql-tools (e.g. sqlcmd) - to add them to the dockerfile or install on the host, see https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-ver15 17 | 18 | > **NOTE** 19 | > The dockerfile uses the Ubuntu 16.04 base image and the matching SQL server repository for SQL server 2019 20 | > in the "CU" version. See https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-change-repo for more info about available repository types (2017/2019 and preview, CU and GDR) 21 | 22 | > **NOTE** 23 | > According to the official documentation for SQL Server on Linux (at https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu?view=sql-server-linux-ver15), 24 | > now also Ubuntu 18.04 is supported - also Docker for Windows is listed (but not which variant: WSL, LCOW, Hyper-V Moby, ... what a mess for _write once ship everywhere_) 25 | 26 | 27 | ## Run 28 | 1. Once you have built the container image, you can run it by running the following command: 29 | ``` 30 | docker run -d \ 31 | -e MSSQL_PID=Developer \ 32 | -e ACCEPT_EULA=Y \ 33 | -e ACCEPT_EULA_ML=Y \ 34 | -e MSSQL_SA_PASSWORD= \ 35 | -v :/var/opt/mssql \ 36 | -p 1433:1433 \ 37 | mssql-server-mlservices 38 | ``` 39 | > **Note:** 40 | > For more configuration options, see https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-configure-docker 41 | 42 | > **Note:** 43 | > You can use any of the following values for MSSQL_PID: Developer (free), Express (free), Enteprise (paid), Standard (paid). If you are using a paid edition, please ensure that you have purchased a license. 44 | 45 | > **Note:** 46 | > Provide an MSSQL_SA_PASSWORD value that meets the [SQL Server password complexity policy](https://docs.microsoft.com/en-us/sql/relational-databases/security/password-policy?view=sql-server-2017). Replace \ with your actual password. 47 | 48 | > **Note:** 49 | > Volume mounting using -v is optional. **Be sure to use volume mounting if you are concerned with preserving the data if the container is ever deleted.** Replace \ with an actual directory where you want to mount the database data and log files. 50 | 51 | > **Note:** 52 | > Volume mounting does work on macOS right now. ([Tracking issue](https://github.com/microsoft/mssql-docker/issues/12)) 53 | 54 | > **Note:** 55 | > By setting the ACCEPT_EULA and ACCEPT_EULA_ML environment variables values to "Y", you are accepting the licensing terms for SQL Server and Machine Learning Services. 56 | 57 | 2. Confirm that the container is running by running the following command: 58 | ``` 59 | docker ps -a 60 | ``` 61 | 62 | ## Use 63 | The repository contains an IPython notebook which can be used from Azure Data Studio (see https://docs.microsoft.com/en-us/sql/azure-data-studio). 64 | 65 | [Open Notebook](/linux/preview/examples/mssql-mlservices/ConfigureAndTestMLServices.ipynb) 66 | 67 | 68 | 1. Connect to Linux SQL Server in the container and enable external script execution by running the following T-SQL statement: 69 | ``` 70 | EXEC sp_configure 'external scripts enabled', 1 71 | RECONFIGURE WITH OVERRIDE 72 | ``` 73 | 74 | > **NOTE** 75 | > If running with sqlcmd, then add semikolons and the GO command after each line. 76 | 77 | 2. Verify ML Services is working by running the following simple R/Python sp_execute_external_script: 78 | ``` 79 | execute sp_execute_external_script 80 | @language = N'R', 81 | @script = N' 82 | print("Hello World!") 83 | print(R.version) 84 | print(Revo.version) 85 | OutputDataSet <- InputDataSet', 86 | @input_data_1 = N'select 1' 87 | go 88 | ``` 89 | 90 | ``` 91 | execute sp_execute_external_script 92 | @language = N'Python', 93 | @script = N' 94 | import sys 95 | print(sys.version) 96 | print("Hello World!") 97 | OutputDataSet = InputDataSet', 98 | @input_data_1 = N'select 1' 99 | go 100 | ``` 101 | -------------------------------------------------------------------------------- /linux/preview/examples/mssql-mlservices/build-container: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | docker build -t mssql-server-mlservices . 3 | -------------------------------------------------------------------------------- /linux/preview/examples/mssql-mlservices/run-container: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | docker container run \ 3 | --name sql-ml \ 4 | --env 'ACCEPT_EULA=Y' \ 5 | --env 'MSSQL_PID=Developer' \ 6 | --env 'ACCEPT_EULA_ML=Y' \ 7 | --env 'MSSQL_SA_PASSWORD=My!SuperSecretPassw0rd' \ 8 | -v /tmp/mssql:/var/opt/mssql \ 9 | --publish 1433:1433 \ 10 | --detach \ 11 | mssql-server-mlservices 12 | 13 | -------------------------------------------------------------------------------- /linux/preview/examples/mssql-mlservices/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | childlogdir=/tmp 3 | logfile=/tmp/supervisord.log 4 | pidfile=/var/run/supervisord.pid 5 | loglevel=trace 6 | nodaemon=true 7 | 8 | [program:sqlservr] 9 | command=/opt/mssql/bin/sqlservr 10 | user=root 11 | stopasgroup=true 12 | retries=3 13 | 14 | [program:launchpadd] 15 | command=/opt/mssql/bin/launchpadd -usens=false 16 | stopasgroup=true 17 | retries=3 18 | -------------------------------------------------------------------------------- /linux/preview/examples/mssql-polybase-fts-tools/Dockerfile: -------------------------------------------------------------------------------- 1 | # Base OS layer: Latest Ubuntu LTS 2 | FROM mcr.microsoft.com/mssql/server:2019-latest 3 | USER root 4 | # Install prerequistes since it is needed to get repo config for SQL server 5 | RUN apt-get update && \ 6 | apt-get install -y software-properties-common && \ 7 | rm -rf /var/lib/apt/lists/* 8 | RUN add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2019.list)" && \ 9 | apt-get install -y mssql-server-fts && \ 10 | apt-get install -y mssql-server-polybase 11 | 12 | EXPOSE 1433 13 | 14 | USER mssql 15 | 16 | # Run SQL Server process 17 | CMD ["/opt/mssql/bin/sqlservr"] 18 | -------------------------------------------------------------------------------- /linux/preview/examples/mssql-polybase/Dockerfile: -------------------------------------------------------------------------------- 1 | # mssql-server-polybase 2 | # Maintainers: Microsoft Corporation 3 | # GitRepo: https://github.com/Microsoft/mssql-docker 4 | 5 | # Base OS layer: Latest Ubuntu LTS 6 | FROM ubuntu:16.04 7 | 8 | # Install prerequistes including repo config for SQL server and PolyBase. 9 | RUN export DEBIAN_FRONTEND=noninteractive && \ 10 | apt-get update && \ 11 | apt-get install -yq apt-transport-https curl && \ 12 | # Get official Microsoft repository configuration 13 | curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \ 14 | curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-preview.list | tee /etc/apt/sources.list.d/mssql-server-preview.list && \ 15 | apt-get update && \ 16 | # Install PolyBase will also install SQL Server via dependency mechanism. 17 | apt-get install -y mssql-server-polybase && \ 18 | # Cleanup the Dockerfile 19 | apt-get clean && \ 20 | rm -rf /var/lib/apt/lists 21 | 22 | # Run SQL Server process 23 | CMD /opt/mssql/bin/sqlservr 24 | -------------------------------------------------------------------------------- /linux/preview/examples/mssql-polybase/README.md: -------------------------------------------------------------------------------- 1 | # List of files 2 | 3 | - `Dockerfile` - main template file 4 | - `README.md` - Instruction to build the image, start a container and test out PolyBase feature. 5 | 6 | # How to build, run, validate the PolyBase docker image 7 | 8 | 1. Download the Dockerfile to your computer. 9 | 2. Build the PolyBase docker image. 10 | - Change to the directory that conttains the downloaded `Dockerfile` 11 | - Run `docker build` command to build the image. 12 | - E.g. `docker build -t mssql-polybase-preview . ` 13 | 14 | 3. Start SQL Server with PolyBase feature. 15 | - Use `docker run` command to run /opt/mssql/bin/sqlservr in an isolated container. 16 | - On bash shell (Linux/macOS/Windows GitBash): 17 | - `$ docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=YourStrong!Passw0rd' -p 1433:1433 -d mssql-polybase-preview` 18 | - On elevated PowerShell command prompt: 19 | - `PS> docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=YourStrong!Passw0rd" -p 1433:1433 -d mssql-polybase-preview` 20 | 21 | 4. Enable PolyBase feature. 22 | - After SQL Server is started with `docker run` command, PolyBase must be enabled to access its features. 23 | - To enable PolyBase, connect to the SQL Server instance and execute the below T-SQL statements. 24 | - `exec sp_configure @configname = 'polybase enabled', @configvalue = 1;` 25 | - `RECONFIGURE;` 26 | 27 | 5. Validate if PolyBase is working. 28 | - After PolyBase feature is enabled, One can run below sample sanity statements to check if PolyBase queries are working. 29 | 30 | ``` 31 | create database PolyTestDb 32 | go 33 | 34 | use PolyTestDb 35 | go 36 | 37 | CREATE TABLE T1 (column1 nvarchar(50)) 38 | GO 39 | 40 | INSERT INTO T1 values ('Hello PolyBase!') 41 | GO 42 | 43 | CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'YourStrong!Master!Passw0rd!' 44 | GO 45 | 46 | CREATE DATABASE SCOPED CREDENTIAL SaCredential WITH IDENTITY = 'sa', Secret = 'YourStrong!Passw0rd' 47 | GO 48 | 49 | CREATE EXTERNAL DATA SOURCE loopback_data_src WITH (LOCATION = 'sqlserver://127.0.0.1', CREDENTIAL = SaCredential) 50 | GO 51 | 52 | CREATE EXTERNAL TABLE T1_external (column1 nvarchar(50)) with (location='PolyTestDb..T1', DATA_SOURCE=loopback_data_src) 53 | GO 54 | 55 | select * from T1_external 56 | GO 57 | ``` 58 | 6. Learn more about PolyBase. 59 | - [PolyBase documentation](https://docs.microsoft.com/en-us/sql/relational-databases/polybase/polybase-guide?view=sql-server-ver15) 60 | 61 | -------------------------------------------------------------------------------- /linux/preview/examples/mssql-rhel7-sql2019/Dockerfile: -------------------------------------------------------------------------------- 1 | # SQL Server 2019 on RHEL 7 sample script 2 | # This is a sample script shared to help create the SQL Server 2019 containers images based on RHEL 7 3 | # This script can be modified to add other SQL Server components like polybase, Full text search, and others. 4 | # Base OS layer: latest RHEL 7 latest image 5 | FROM registry.access.redhat.com/rhel7:latest 6 | 7 | ## Adding the required repos for installing SQL Server, tools, and other dependent packages. 8 | RUN REPOLIST=rhel-7-server-rpms,packages-microsoft-com-mssql-server-2019,packages-microsoft-com-prod && \ 9 | curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2019.repo && \ 10 | curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo && \ 11 | ACCEPT_EULA=Y yum -y install --disablerepo "*" --enablerepo ${REPOLIST} --setopt=tsflags=nodocs \ 12 | mssql-server mssql-tools unixODBC-devel && \ 13 | yum clean all 14 | 15 | ## Providing the required access to the mssql server folders 16 | RUN mkdir -p -m 770 /var/opt/mssql && chown -R mssql. /var/opt/mssql 17 | 18 | ## Default SQL Server port 19 | EXPOSE 1433 20 | 21 | ## Running SQL containers as non-root 22 | USER mssql 23 | 24 | ## Start SQL server 25 | CMD /opt/mssql/bin/sqlservr 26 | -------------------------------------------------------------------------------- /linux/preview/examples/mssql-rhel8-sql2017/Dockerfile: -------------------------------------------------------------------------------- 1 | # SQL Server 2017 on RHEL 8 ubi Sample 2 | # This is a sample script shared to help create the SQL Server 2017 containers images based on RHEL 8 3 | # This script can be modified to add other SQL Server components like polybase, Full text search, and others. 4 | # Base OS layer: latest RHEL 8 ubi image 5 | FROM registry.access.redhat.com/ubi8:latest 6 | 7 | # You need to ensure that the host where you are building this image has repos subscribed that are required to install the package dependencies, like python3, bzip2, and many more. 8 | # Adding repositories and installing SQL Server and tools packages 9 | RUN REPOLIST=rhel-8-for-x86_64-baseos-rpms,rhel-8-for-x86_64-appstream-rpms,packages-microsoft-com-mssql-server-2017,packages-microsoft-com-prod && \ 10 | curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2017.repo && \ 11 | curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/8/prod.repo && \ 12 | ACCEPT_EULA=Y yum -y install --disablerepo "*" --enablerepo ${REPOLIST} --setopt=tsflags=nodocs \ 13 | mssql-server mssql-tools unixODBC-devel && \ 14 | yum clean all 15 | 16 | ## Adding the required non-root mssql user and also giving access to the mssql server folders 17 | RUN useradd -M -s /bin/bash -u 10001 -g 0 mssql 18 | RUN mkdir -p -m 770 /var/opt/mssql && chown -R mssql. /var/opt/mssql 19 | 20 | ## Containers not to be run as root, so accessing it as mssql user. 21 | USER mssql 22 | 23 | # Default SQL Server TCP/Port 24 | EXPOSE 1433 25 | 26 | # Run SQL Server binary 27 | CMD ["/opt/mssql/bin/sqlservr"] 28 | -------------------------------------------------------------------------------- /linux/preview/examples/mssql-server-linux-non-root/Dockerfile: -------------------------------------------------------------------------------- 1 | # Exmple of creating a container image that will run as a user 'mssql' instead of root 2 | # This is example is based on the official image from Microsoft and effectively changes the user that SQL Server runs as 3 | # and allows for dumps to generate as a non-root user 4 | 5 | 6 | FROM mcr.microsoft.com/mssql/server:2017-latest 7 | 8 | # Create non-root user and update permissions 9 | # 10 | RUN useradd -M -s /bin/bash -u 10001 -g 0 mssql 11 | RUN mkdir -p -m 770 /var/opt/mssql && chgrp -R 0 /var/opt/mssql 12 | 13 | # Grant sql the permissions to connect to ports <1024 as a non-root user 14 | # 15 | RUN setcap 'cap_net_bind_service+ep' /opt/mssql/bin/sqlservr 16 | 17 | # Allow dumps from the non-root process 18 | # 19 | RUN setcap 'cap_sys_ptrace+ep' /opt/mssql/bin/paldumper 20 | RUN setcap 'cap_sys_ptrace+ep' /usr/bin/gdb 21 | 22 | # Add an ldconfig file because setcap causes the os to remove LD_LIBRARY_PATH 23 | # and other env variables that control dynamic linking 24 | # 25 | RUN mkdir -p /etc/ld.so.conf.d && touch /etc/ld.so.conf.d/mssql.conf 26 | RUN echo -e "# mssql libs\n/opt/mssql/lib" >> /etc/ld.so.conf.d/mssql.conf 27 | RUN ldconfig 28 | 29 | USER mssql 30 | CMD ["/opt/mssql/bin/sqlservr"] 31 | -------------------------------------------------------------------------------- /linux/preview/examples/mssql-server-linux-non-root/Dockerfile-2019: -------------------------------------------------------------------------------- 1 | # Exmple of creating a SQL Server 2019 container image that will run as a user 'mssql' instead of root 2 | # This is example is based on the official image from Microsoft and effectively changes the user that SQL Server runs as 3 | # and allows for dumps to generate as a non-root user 4 | 5 | 6 | FROM mcr.microsoft.com/mssql/server:2019-latest 7 | 8 | # Create non-root user and update permissions 9 | # 10 | RUN useradd -M -s /bin/bash -u 10001 -g 0 mssql 11 | RUN mkdir -p -m 770 /var/opt/mssql && chgrp -R 0 /var/opt/mssql 12 | 13 | # Grant sql the permissions to connect to ports <1024 as a non-root user 14 | # 15 | RUN setcap 'cap_net_bind_service+ep' /opt/mssql/bin/sqlservr 16 | 17 | # Allow dumps from the non-root process 18 | # 19 | RUN setcap 'cap_sys_ptrace+ep' /opt/mssql/bin/paldumper 20 | RUN setcap 'cap_sys_ptrace+ep' /usr/bin/gdb 21 | 22 | # Add an ldconfig file because setcap causes the os to remove LD_LIBRARY_PATH 23 | # and other env variables that control dynamic linking 24 | # 25 | RUN mkdir -p /etc/ld.so.conf.d && touch /etc/ld.so.conf.d/mssql.conf 26 | RUN echo -e "# mssql libs\n/opt/mssql/lib" >> /etc/ld.so.conf.d/mssql.conf 27 | RUN ldconfig 28 | 29 | USER mssql 30 | CMD ["/opt/mssql/bin/sqlservr"] 31 | -------------------------------------------------------------------------------- /linux/preview/openSUSE/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM opensuse/leap:15.4 2 | 3 | RUN zypper install --no-confirm --no-recommends \ 4 | # install setcap to be used later 5 | # curl is needed for rpm import 6 | libcap-progs curl && \ 7 | rpm --import https://packages.microsoft.com/keys/microsoft.asc && \ 8 | zypper rm --no-confirm --clean-deps curl 9 | 10 | # consider merging the two RUNs to save ~ 100mb at the cost of caching adding the signing key 11 | 12 | # add mssql-server repo 13 | RUN zypper addrepo --no-check https://packages.microsoft.com/config/sles/15/mssql-server-2019.repo && \ 14 | zypper refresh packages-microsoft-com-mssql-server-2019 && \ 15 | # install mssql-server 16 | zypper install --no-confirm --auto-agree-with-licenses --no-recommends mssql-server && \ 17 | zypper clean --all && \ 18 | # post installation of SQL Server the mssql user/group is created 19 | # so set the right permissions to the msssql folder 20 | mkdir -p -m 770 /var/opt/mssql && \ 21 | chown -R mssql /var/opt/mssql && \ 22 | # grant sql the permissions to connect to ports <1024 as a non-root user 23 | setcap 'cap_net_bind_service+ep' /opt/mssql/bin/sqlservr && \ 24 | # allow dumps from the non-root process 25 | setcap 'cap_sys_ptrace+ep' /opt/mssql/bin/paldumper && \ 26 | setcap 'cap_sys_ptrace+ep' /usr/bin/gdb && \ 27 | # ldconfig file because setcap causes the os to remove LD_LIBRARY_PATH 28 | # and other env variables that control dynamic linking 29 | mkdir -p /etc/ld.so.conf.d && \ 30 | touch /etc/ld.so.conf.d/mssql.conf && \ 31 | echo -e "# mssql libs\n/opt/mssql/lib" >> /etc/ld.so.conf.d/mssql.conf && \ 32 | ldconfig 33 | 34 | EXPOSE 1433 35 | 36 | USER mssql 37 | 38 | CMD ["/opt/mssql/bin/sqlservr"] 39 | -------------------------------------------------------------------------------- /linux/preview/openSUSE/README.md: -------------------------------------------------------------------------------- 1 | # How to build a SQL Server on openSUSE container image 2 | 3 | **Steps to building SQL Server on openSUSE container image** 4 | 5 | 1. [optional] Customize the mssql.conf file. Example mssql.conf entries can be found here: https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-configure-mssql-conf?view=sql-server-2017#mssql-conf-format 6 | 7 | 2. Build the docker image. 8 | ``` 9 | docker build . -t mssql-opensuse 10 | ``` 11 | 3. Run the docker image. 12 | ``` 13 | sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=' \ 14 | -p 1433:1433 --name sql1 \ 15 | -d mssql-opensuse 16 | ``` 17 | -------------------------------------------------------------------------------- /linux/preview/openSUSE/mssql.conf: -------------------------------------------------------------------------------- 1 | [example] 2 | var = value -------------------------------------------------------------------------------- /linux/rancher/.gitignore: -------------------------------------------------------------------------------- 1 | jy-sql.yaml 2 | -------------------------------------------------------------------------------- /linux/rancher/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | name: sql-server-rancher 3 | description: A Helm chart for SQL Server on Rancher 4 | 5 | # A chart can be either an 'application' or a 'library' chart. 6 | # 7 | # Application charts are a collection of templates that can be packaged into versioned archives 8 | # to be deployed. 9 | # 10 | # Library charts provide useful utilities or functions for the chart developer. They're included as 11 | # a dependency of application charts to inject those utilities and functions into the rendering 12 | # pipeline. Library charts do not define any templates and therefore cannot be deployed. 13 | type: application 14 | 15 | # This is the chart version. This version number should be incremented each time you make changes 16 | # to the chart and its templates, including the app version. 17 | # Versions are expected to follow Semantic Versioning (https://semver.org/) 18 | version: 0.0.2 19 | 20 | # This is the version number of the application being deployed. This version number should be 21 | # incremented each time you make changes to the application. Versions are not expected to 22 | # follow Semantic Versioning. They should reflect the version the application is using. 23 | appVersion: 2019.cu15 24 | 25 | icon: https://docs.microsoft.com/vi-vn/troubleshoot/media/hub-landing/sql-database-blue.svg 26 | -------------------------------------------------------------------------------- /linux/rancher/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: lint dry-run 2 | 3 | lint: 4 | helm lint --values ./values.test.yaml 5 | 6 | template: 7 | helm template --values ./values.test.yaml . --debug 8 | -------------------------------------------------------------------------------- /linux/rancher/app-readme.md: -------------------------------------------------------------------------------- 1 | # SQL Server 2 | 3 | [Microsoft SQL Server](https://en.wikipedia.org/wiki/Microsoft_SQL_Server/) is a relational database management system developed by Microsoft. As a database server, it is a software product with the primary function of storing and retrieving data as requested by other software applications—which may run either on the same computer or on another computer across a network (including the Internet). Microsoft markets at least a dozen different editions of Microsoft SQL Server, aimed at different audiences and for workloads ranging from small single-machine applications to large Internet-facing applications with many concurrent users. 4 | 5 | This helm chart creates a SQL Server workload using StatefulSet along with a Service and Azure Disk storage class. 6 | -------------------------------------------------------------------------------- /linux/rancher/questions.yml: -------------------------------------------------------------------------------- 1 | questions: 2 | - variable: mssql.conf.eula.accepteula 3 | label: Accept the SQL Server EULA 4 | # no current support for html 5 | # description: Accepts the SQL Server EULA (any value confirms acceptance). 6 | description: Accepts the SQL Server EULA (any value confirms acceptance). The EULA is posted @ http://go.microsoft.com/fwlink/?LinkId=746388 7 | required: true 8 | default: true 9 | group: SQL Server options 10 | 11 | - variable: USE_PRODUCT_KEY 12 | label: Use a SQL Server Product Key 13 | description: Enter a Product Key instead of choosing a SQL Server Edition 14 | type: boolean 15 | default: false 16 | group: SQL Server options 17 | 18 | - variable: mssql.pid 19 | label: SQL Server Edition aka. MSSQL_PID 20 | description: Select a SQL Server Edition 21 | type: enum 22 | options: 23 | - Evaluation 24 | - Developer 25 | - Express 26 | - Web 27 | - Standard 28 | - Enterprise 29 | required: true 30 | default: Developer 31 | show_if: USE_PRODUCT_KEY=false 32 | group: SQL Server options 33 | 34 | - variable: mssql.pid 35 | label: SQL Server License Key 36 | description: Enter a Product Key of the format "#####-#####-#####-#####-#####" 37 | required: true 38 | show_if: USE_PRODUCT_KEY=true 39 | group: SQL Server options 40 | 41 | - variable: mssql.sa.password 42 | label: MSSQL SA user password 43 | description: Sets the SA user password. Password requirements @ https://docs.microsoft.com/en-us/sql/relational-databases/security/password-policy?view=sql-server-ver15#password-complexity 44 | type: password 45 | min: 8 46 | max: 128 47 | default: "" 48 | valid_chars: a-zA-Z0-9(`~!@#$%^&*_-+=|\\{}[]:;\"'<>,.?)/ 49 | required: true 50 | group: SQL Server options 51 | 52 | - variable: mssql.conf.lcid 53 | label: SQL Server Locale 54 | description: Sets SQL Server Locale 55 | group: SQL Server options 56 | 57 | - variable: mssql.conf.sqlagent.enabled 58 | label: Enable SQL Server Agent 59 | description: Enables the SQL Server Agent 60 | type: boolean 61 | default: true 62 | group: SQL Server options 63 | 64 | - variable: defaultContainerImage 65 | label: Use default SQL Server container image 66 | type: boolean 67 | default: true 68 | show_subquestion_if: false 69 | group: Container Image Options 70 | subquestions: 71 | - variable: statefulset.template.spec.containers.sqlServer.image.repository 72 | description: Image Repository 73 | label: Image Repository 74 | - variable: statefulset.template.spec.containers.sqlServer.image.pullPolicy 75 | label: Image Pull Policy 76 | type: enum 77 | options: 78 | - IfNotPresent 79 | - Always 80 | - Never 81 | - variable: statefulset.template.spec.containers.sqlServer.image.tag 82 | label: Image Tag 83 | 84 | - variable: statefulset.template.spec.securityContext.fsGroup 85 | description: | 86 | Specifies a supplementary group id for all pod processes 87 | See https://kubernetes.io/docs/tasks/configure-pod-container/security-context for 88 | additional details. 89 | label: statefulset.template.spec.securityContext.fsGroup 90 | group: Kubernetes Statefulset options 91 | 92 | - variable: statefulset.template.spec.containers.sqlServer.ports.databaseEngineContainerPort 93 | description: > 94 | Specifies containerPort for SQL Server Database Engine 95 | label: SQL Server Database Engine Container Port 96 | group: Kubernetes Statefulset Options 97 | 98 | - variable: service.spec.ports.sqlServerDatabasePort 99 | description: Kubernetes service port for SQL Server 100 | group: Kubernetes Service Options 101 | label: Kubernetes Service Port 102 | type: int 103 | 104 | - variable: storageClass.provisioner 105 | description: StorageClass provisioner for SQL Server 106 | group: Kubernetes Storage Options 107 | label: Kubernetes StorageClass Provisioner 108 | type: enum 109 | options: 110 | - disk.csi.azure.com 111 | - ebs.csi.aws.com 112 | - pd.csi.storage.gke.io 113 | 114 | - variable: storageClass.type 115 | description: StorageClass Type for Azure Disk CSI. CSI Drivers are default after k8s v1.21 116 | group: Kubernetes Storage Options 117 | label: Kubernetes StorageClass Type 118 | show_if: "storageClass.provisioner=disk.csi.azure.com" 119 | type: enum 120 | default: Standard_LRS 121 | options: 122 | - Standard_LRS 123 | - Premium_LRS 124 | - StandardSSD_LRS 125 | - UltraSSD_LRS 126 | 127 | - variable: storageClass.type 128 | description: StorageClass Type for AWS EBS CSI. Install the csi driver on the target cluster first. https://docs.aws.amazon.com/eks/latest/userguide/managing-ebs-csi.html#adding-ebs-csi-eks-add-on 129 | group: Kubernetes Storage Options 130 | label: Kubernetes StorageClass Type 131 | show_if: "storageClass.provisioner=ebs.csi.aws.com" 132 | type: enum 133 | default: standard 134 | options: 135 | - io1 136 | - io2 137 | - gp2 138 | - gp3 139 | - sc1 140 | - st1 141 | - standard 142 | 143 | - variable: storageClass.type 144 | description: StorageClass Type for GCE PD CSI. CSI Driver are default after Linux clusters 1.18.10-gke.2100 or 1.19.3-gke.2100 145 | group: Kubernetes Storage Options 146 | label: Kubernetes StorageClass Type 147 | show_if: "storageClass.provisioner=pd.csi.storage.gke.io" 148 | type: enum 149 | default: pd-standard 150 | options: 151 | - pd-standard 152 | - pd-balanced 153 | - pd-ssd 154 | - pd-extreme 155 | 156 | - variable: storage.size 157 | description: Size for Storage Volume in Gibibytes (Gi) 158 | group: Kubernetes Storage Options 159 | label: Kubernetes Storage Size 160 | -------------------------------------------------------------------------------- /linux/rancher/readme.md: -------------------------------------------------------------------------------- 1 | # SQL Server Chart for Rancher 2 | This helm chart provided for reference to help guide with SQL Server deployments on SUSE Rancher with no warranties or support. While it will be geared towards using on Rancher it's simply a helm chart so can be used in any helm deployments. 3 | 4 | ## Prerequisites: 5 | 1. Kubernetes 1.19+ cluster 6 | 1. [Helm >= 3.2 client](https://helm.sh/docs/intro/install) installed on the machine where you will deploy from 7 | 1. Connectivity to the Kubenetes cluster api endpoint from your machine 8 | 1. [kubeconfig](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/) for the cluster you will deploy to with `cluster-admin` permissions. 9 | 10 | ## Chart Usage 11 | 12 | ### SQL Server EULA 13 | NOTE: By deploying this Chart you are agreeing to the [SQL Server EULA](http://go.microsoft.com/fwlink/?LinkId=746388) 14 | 15 | ### Quickstart 16 | 1. Clone this repo. 17 | 1. Change to the repo directory 18 | - `cd linux/rancher` 19 | 1. Change the `sa` password in [values.example.yaml](./values.example.yaml) 20 | 1. Deploy the chart with: 21 | - `helm install --create-namespace -n sql-server -f values.example.yaml .` 22 | 23 | ### Defaults: 24 | For chart defaults take a look at [values.yaml](./values.yaml). Some notable ones are: 25 | - `mssql.pid` to change the SQL Server edition 26 | - `statefulset.template.spec.containers.sqlServer.image` to change the deployed image 27 | 28 | ### StorageClasses 29 | By default the chart uses the default storage class of the cluster. You can configure a 30 | CSI storage class for AKS/GKE/EKS. Please see [values.test.yaml](./values.test.yaml) for an example. 31 | Further details are in [storageclass.yaml](./templates/storageclass.yaml) 32 | 33 | 34 | ## Contributing 35 | Contributions are welcome. Please open a pull request. Remember to: 36 | - bump the version in [Chart.yaml](./Chart.yaml#18) accordingly 37 | - add any defaults to [values.yaml](./values.yaml) 38 | - add variables to be tested in [values.test.yaml](./values.test.yaml) 39 | - ensure the lint passes with `make lint` 40 | - test your changes on a deployment 41 | -------------------------------------------------------------------------------- /linux/rancher/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* 2 | Expand the name of the chart. 3 | */}} 4 | {{- define "sql-server-rancher.name" -}} 5 | {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} 6 | {{- end }} 7 | 8 | {{/* 9 | Create a default fully qualified app name. 10 | We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). 11 | If release name contains chart name it will be used as a full name. 12 | */}} 13 | {{- define "sql-server-rancher.fullname" -}} 14 | {{- if .Values.fullnameOverride }} 15 | {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} 16 | {{- else }} 17 | {{- $name := default .Chart.Name .Values.nameOverride }} 18 | {{- if contains $name .Release.Name }} 19 | {{- .Release.Name | trunc 63 | trimSuffix "-" }} 20 | {{- else }} 21 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} 22 | {{- end }} 23 | {{- end }} 24 | {{- end }} 25 | 26 | {{/* 27 | Create chart name and version as used by the chart label. 28 | */}} 29 | {{- define "sql-server-rancher.chart" -}} 30 | {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} 31 | {{- end }} 32 | 33 | {{/* 34 | Common labels 35 | */}} 36 | {{- define "sql-server-rancher.labels" -}} 37 | helm.sh/chart: {{ include "sql-server-rancher.chart" . }} 38 | {{ include "sql-server-rancher.selectorLabels" . }} 39 | {{- if .Chart.AppVersion }} 40 | app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} 41 | {{- end }} 42 | app.kubernetes.io/managed-by: {{ .Release.Service }} 43 | {{- end }} 44 | 45 | {{/* 46 | Selector labels 47 | */}} 48 | {{- define "sql-server-rancher.selectorLabels" -}} 49 | app.kubernetes.io/name: {{ include "sql-server-rancher.name" . }} 50 | app.kubernetes.io/instance: {{ .Release.Name }} 51 | {{- end }} 52 | 53 | {{/* 54 | Create the name of the service account to use 55 | */}} 56 | {{- define "sql-server-rancher.serviceAccountName" -}} 57 | {{- if .Values.serviceAccount.create }} 58 | {{- default (include "sql-server-rancher.fullname" .) .Values.serviceAccount.name }} 59 | {{- else }} 60 | {{- default "default" .Values.serviceAccount.name }} 61 | {{- end }} 62 | {{- end }} 63 | -------------------------------------------------------------------------------- /linux/rancher/templates/configmap.yaml: -------------------------------------------------------------------------------- 1 | kind: ConfigMap 2 | apiVersion: v1 3 | metadata: 4 | name: mssql 5 | data: 6 | mssql.conf: | 7 | [EULA] 8 | accepteula = {{ .Values.mssql.conf.eula.accepteula }} 9 | accepteulaml = {{ .Values.mssql.conf.eula.accepteulaml }} 10 | 11 | [coredump] 12 | captureminiandfull = true 13 | coredumptype = full 14 | 15 | [hadr] 16 | hadrenabled = 1 17 | 18 | [language] 19 | lcid = {{ .Values.mssql.conf.lcid }} 20 | 21 | [sqlagent] 22 | enabled = {{ .Values.mssql.conf.sqlagent.enabled }} 23 | 24 | 25 | # control.alternatewritethrough Enable optimized write through flush for O_DSYNC requests 26 | # control.hestacksize Host extension stack size in KB 27 | # control.stoponguestprocessfault Stops the process if any guest process reports unhandled exception 28 | # control.writethrough Use O_DSYNC for file flag write through requests 29 | # coredump.captureminiandfull Capture both mini and full core dumps 30 | # coredump.coredumptype Core dump type to capture: mini, miniplus, filtered, full 31 | # distributedtransaction.allowonlysecurerpccalls Configure secure only rpc calls for distributed transactions 32 | # distributedtransaction.fallbacktounsecurerpcifnecessary Configure security only rpc calls for distributed transactions 33 | # distributedtransaction.maxlogsize DTC log file size in MB. Default is 64MB 34 | # distributedtransaction.memorybuffersize Circular buffer size in which traces are stored. This size is in MB and default is 10MB 35 | # distributedtransaction.servertcpport MSDTC rpc server port 36 | # distributedtransaction.trace_cm Traces in the connection manager 37 | # distributedtransaction.trace_contact Traces the contact pool and contacts 38 | # distributedtransaction.trace_gateway Traces Gateway source 39 | # distributedtransaction.trace_log Log tracing 40 | # distributedtransaction.trace_misc Traces that cannot be categorized into the other categories 41 | # distributedtransaction.trace_proxy Traces that are generated in the MSDTC proxy 42 | # distributedtransaction.trace_svc Traces service and .exe file startup 43 | # distributedtransaction.trace_trace The trace infrastructure itself 44 | # distributedtransaction.trace_util Traces utility routines that are called from multiple locations 45 | # distributedtransaction.trace_xa XA Transaction Manager (XATM) tracing source 46 | # distributedtransaction.tracefilepath Folder in which trace files should be stored 47 | # distributedtransaction.turnoffrpcsecurity Enable or disable RPC security for distributed transactions 48 | # errorlog.numerrorlogs Number of error log maintained before cycling the log. 49 | # extensibility.datadirectories Colon separated directory paths available to sp_execute_external_script 50 | # extensibility.outboundnetworkaccess Enable outbound network access for sp_execute_external_script 51 | # filelocation.defaultbackupdir Default directory for backup files 52 | # filelocation.defaultdatadir Default directory for data files 53 | # filelocation.defaultdumpdir Default directory for crash dump files 54 | # filelocation.defaultlogdir Default directory for log files 55 | # filelocation.errorlogfile Error log file location 56 | # filelocation.masterdatafile Master database data file location 57 | # filelocation.masterlogfile Master database log file location 58 | # hadr.hadrenabled Allow SQL Server to use availability groups for high availability and disaster recovery 59 | # language.lcid Locale identifier for SQL Server to use (e.g. 1033 for US - English) 60 | # memory.disablememorypressure SQL Server disable memory pressure 61 | # memory.memory_optimized Enable or disable SQL Server memory optimized features - persistent memory file enlightenment, memory protection 62 | # memory.memorylimitmb SQL Server memory limit (megabytes) 63 | # network.disablesssd Disable querying SSSD for AD account information and default to LDAP calls 64 | # network.enablekdcfromkrb5conf Enable looking up KDC information from krb5.conf 65 | # network.forceencryption Force encryption of incoming client connections 66 | # network.forcesecureldap Force using LDAPS to contact domain controller 67 | # network.ipaddress IP address for incoming connections 68 | # network.kerberoscredupdatefrequency Time in seconds between checks for kerberos credentials that need to be updated 69 | # network.kerberoskeytabfile Kerberos keytab file location 70 | # network.privilegedadaccount Privileged AD user to use for AD authentication 71 | # network.rpcport TCP port for Rpc endpoint mapper 72 | # network.tcpport TCP port for incoming connections 73 | # network.tlscert Path to certificate file for encrypting incoming client connections 74 | # network.tlsciphers TLS ciphers allowed for encrypted incoming client connections 75 | # network.tlskey Path to private key file for encrypting incoming client connections 76 | # network.tlsprotocols TLS protocol versions allowed for encrypted incoming client connections 77 | # sqlagent.databasemailprofile SQL Agent Database Mail profile name 78 | # sqlagent.enabled Enable or disable SQLAgent 79 | # sqlagent.errorlogfile SQL Agent log file path 80 | # sqlagent.errorlogginglevel SQL Agent logging level bitmask - 1=Errors, 2=Warnings, 4=Info 81 | # sqlagent.startupwaitforalldb Set to 1 (default) if SqlAgent should wait for all databases on startup; set to 0 to wait for MSDB only 82 | # telemetry.customerfeedback Telemetry status 83 | # telemetry.userrequestedlocalauditdirectory Directory for telemetry local audit cache 84 | # uncmapping. Maps UNC path to a local path. (e.g. ./mssql-conf set uncmapping //servername/sharename /tmp/folder) -------------------------------------------------------------------------------- /linux/rancher/templates/secret.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: mssql-secret 5 | labels: 6 | {{- include "sql-server-rancher.labels" . | nindent 4 }} 7 | type: Opaque 8 | data: 9 | mssql_sa_password : {{ .Values.mssql.sa.password | b64enc | quote }} 10 | -------------------------------------------------------------------------------- /linux/rancher/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ include "sql-server-rancher.fullname" . }} 5 | labels: 6 | {{- include "sql-server-rancher.labels" . | nindent 4 }} 7 | spec: 8 | clusterIP: None 9 | ports: 10 | - port: {{ .Values.service.spec.ports.sqlServerDatabasePort }} 11 | targetPort: http 12 | protocol: TCP 13 | selector: 14 | {{- include "sql-server-rancher.selectorLabels" . | nindent 4 }} 15 | -------------------------------------------------------------------------------- /linux/rancher/templates/statefulset.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: StatefulSet 3 | metadata: 4 | name: {{ include "sql-server-rancher.fullname" . }} 5 | labels: 6 | {{- include "sql-server-rancher.labels" . | nindent 4 }} 7 | spec: 8 | serviceName: {{ include "sql-server-rancher.fullname" . }} 9 | replicas: 1 10 | selector: 11 | matchLabels: 12 | {{- include "sql-server-rancher.selectorLabels" . | nindent 6 }} 13 | template: 14 | metadata: 15 | {{- with .Values.statefulset.template.metadata.annotations }} 16 | annotations: 17 | {{- toYaml . | nindent 8 }} 18 | {{- end }} 19 | labels: 20 | {{- include "sql-server-rancher.selectorLabels" . | nindent 8 }} 21 | spec: 22 | securityContext: 23 | {{- toYaml .Values.statefulset.template.spec.securityContext | nindent 8 }} 24 | containers: 25 | - name: {{ .Chart.Name }} 26 | command: 27 | - /bin/bash 28 | - -c 29 | - /opt/mssql/bin/sqlservr 30 | image: {{ .Values.statefulset.template.spec.containers.sqlServer.image.repository }}:{{ .Values.statefulset.template.spec.containers.sqlServer.image.tag | default .Chart.AppVersion }} 31 | imagePullPolicy: {{ .Values.statefulset.template.spec.containers.sqlServer.image.pullPolicy }} 32 | ports: 33 | - containerPort: {{ .Values.statefulset.template.spec.containers.sqlServer.ports.databaseEngineContainerPort }} 34 | env: 35 | # prefer mssql-config ConfigMap over env vars 36 | - name: MSSQL_PID 37 | value: {{ .Values.mssql.pid }} 38 | - name: MSSQL_SA_PASSWORD 39 | valueFrom: 40 | secretKeyRef: 41 | name: mssql-secret 42 | key: mssql_sa_password 43 | volumeMounts: 44 | - name: mssql 45 | mountPath: /var/opt/mssql 46 | - name: mssql-config 47 | mountPath: /var/opt/mssql/mssql.conf 48 | subPath: mssql.conf 49 | {{- if .Values.statefulset.template.spec.containers.sqlServer.extraVolumeMounts }} 50 | {{- toYaml .Values.statefulset.template.spec.containers.sqlServer.extraVolumeMounts | nindent 12 }} 51 | {{- end }} 52 | volumes: 53 | - name: mssql-config 54 | configMap: 55 | name: mssql 56 | {{- if .Values.statefulset.template.spec.volumes.extraVolumes }} 57 | {{- toYaml .Values.statefulset.template.spec.volumes.extraVolumes | nindent 8 }} 58 | {{- end }} 59 | volumeClaimTemplates: 60 | - metadata: 61 | name: mssql 62 | spec: 63 | accessModes: 64 | - ReadWriteOnce 65 | resources: 66 | requests: 67 | storage: {{ .Values.storage.size }}Gi 68 | {{- if .Values.storageClass.provisioner }} 69 | storageClassName: {{ .Values.storageClass.provisioner }} 70 | {{- end }} 71 | -------------------------------------------------------------------------------- /linux/rancher/templates/storageclass.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.storageClass.provisioner -}} 2 | kind: StorageClass 3 | apiVersion: storage.k8s.io/v1 4 | metadata: 5 | name: {{ .Values.storageClass.provisioner }} 6 | provisioner: {{ .Values.storageClass.provisioner }} 7 | reclaimPolicy: Delete 8 | allowVolumeExpansion: true 9 | mountOptions: 10 | - noatime 11 | parameters: 12 | {{- if eq .Values.storageClass.provisioner "disk.csi.azure.com" }} 13 | storageAccountType: {{ .Values.storageClass.type }} 14 | fsType: xfs 15 | {{- else if eq .Values.storageClass.provisioner "ebs.csi.aws.com" }} 16 | csi.storage.k8s.io/fstype: xfs 17 | type: {{ .Values.storageClass.type }} 18 | {{- else if eq .Values.storageClass.provisioner "pd.csi.storage.gke.io" }} 19 | csi.storage.k8s.io/fstype: xfs 20 | type: {{ .Values.storageClass.type }} 21 | {{- end }} 22 | {{- end -}} 23 | 24 | -------------------------------------------------------------------------------- /linux/rancher/values.example.yaml: -------------------------------------------------------------------------------- 1 | mssql: 2 | sa: 3 | password: Sfr9nxVVkbMVGTQweKmD 4 | -------------------------------------------------------------------------------- /linux/rancher/values.test.yaml: -------------------------------------------------------------------------------- 1 | # since a default SA_PASSWORD is not set, this is used for helm lint and helm debug, otherwise unused 2 | mssql: 3 | sa: 4 | password: Sfr9nxVVkbMVGTQweKmD 5 | 6 | storageClass: 7 | provisioner: disk.csi.azure.com 8 | type: Standard_LRS 9 | 10 | statefulset: 11 | template: 12 | spec: 13 | containers: 14 | sqlServer: 15 | extraVolumeMounts: 16 | - name: secrets-store 17 | mountPath: /mnt/secrets-store 18 | readOnly: true 19 | volumes: 20 | extraVolumes: 21 | - name: secrets-store 22 | csi: 23 | driver: secrets-store.csi.k8s.io 24 | readOnly: true 25 | volumeAttributes: 26 | secretProviderClass: azure-sync 27 | -------------------------------------------------------------------------------- /linux/rancher/values.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | mssql: 4 | pid: Developer 5 | conf: 6 | eula: 7 | accepteula: true 8 | accepteulaml: true 9 | lcid: 1033 # english 10 | sqlagent: 11 | enabled: true 12 | 13 | statefulset: 14 | template: 15 | metadata: 16 | annotations: {} 17 | spec: 18 | containers: 19 | sqlServer: 20 | image: 21 | repository: mcr.microsoft.com/mssql/server 22 | pullPolicy: IfNotPresent 23 | tag: 2019-latest 24 | ports: 25 | databaseEngineContainerPort: 1433 26 | extraVolumeMounts: [] 27 | volumes: 28 | extraVolumes: [] 29 | securityContext: 30 | fsGroup: 10001 31 | 32 | service: 33 | spec: 34 | ports: 35 | sqlServerDatabasePort: 1433 36 | 37 | storageClass: 38 | provisioner: null 39 | type: null 40 | 41 | storage: 42 | size: 8 43 | -------------------------------------------------------------------------------- /linux/sample-helm-chart-statefulset-deployment/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *.orig 18 | *~ 19 | # Various IDEs 20 | .project 21 | .idea/ 22 | *.tmproj 23 | .vscode/ 24 | -------------------------------------------------------------------------------- /linux/sample-helm-chart-statefulset-deployment/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | name: sql-statefull-deploy 3 | description: A Helm chart for Kubernetes 4 | 5 | # A chart can be either an 'application' or a 'library' chart. 6 | # 7 | # Application charts are a collection of templates that can be packaged into versioned archives 8 | # to be deployed. 9 | # 10 | # Library charts provide useful utilities or functions for the chart developer. They're included as 11 | # a dependency of application charts to inject those utilities and functions into the rendering 12 | # pipeline. Library charts do not define any templates and therefore cannot be deployed. 13 | type: application 14 | 15 | # This is the chart version. This version number should be incremented each time you make changes 16 | # to the chart and its templates, including the app version. 17 | # Versions are expected to follow Semantic Versioning (https://semver.org/) 18 | version: 0.1.1 19 | 20 | # This is the version number of the application being deployed. This version number should be 21 | # incremented each time you make changes to the application. Versions are not expected to 22 | # follow Semantic Versioning. They should reflect the version the application is using. 23 | appVersion: 1.16.0 24 | 25 | annotations: 26 | catalog.cattle.io/hidden: "true" # hide from Rancher catalog 27 | -------------------------------------------------------------------------------- /linux/sample-helm-chart-statefulset-deployment/readme.md: -------------------------------------------------------------------------------- 1 | # Readme.md 2 | 3 | This HELM chart is a sample "as-is" chart provided for reference to help guide with SQL Server deployment on Kubernetes cluster. 4 | 5 | ## Prerequisites: 6 | 7 | 1. This chart is built on helm v3. It requires a kubernetes cluster to be running for you to deploy SQL container using this chart. 8 | 2. Ensure you have the helm installed on the client from where you will connect to the kubernetes cluster to deploy using the helm chart. 9 | 3. For minimum hardware requirement for the host to run SQL Server containers please refer to the system requirements section for SQL on Linux. 10 | 4. Requires the following variables to be set or changed in the values.yaml file :
11 | a. Please ensure that you accept the EULA for SQL Server, by changing the value of ACCEPT_EULA.value=y in values.yaml file or set it during the helm install command --set ACCEPT_EULA.value=Y.
12 | b. Please do choose the right edition of SQL Server that you would like to install you can change the value of the MSSQL_PID.value in the values file to the edition that you want to install or you can also 13 | change it during the helm install command using the option --set MSSQL_PID.value=Enterprise, If you do not pass the flag and do not change it in the yaml, then by default it is going to install developer edition.
c. Also please do provide your customized value for the sa_password, if you do not provide it then by default the sa_password will the value as shown in the below table.
14 | 15 | Note: Once you deploy SQL server containers using the chart below, please log into SQL Server using sa account and change the password for sa, this ensures that as DBA you have the control of the sa user and password. 16 | 17 | 18 | ## Chart usage: 19 | 20 | On the client machine where you have the Helm tools installed, download the chart on your machine and make the required changes to the values.yaml file as per your requirement. To see the list of settings that can be changed using the values.yaml file please refer to the table below. 21 | 22 | 23 | 24 | | Configuration parameters | Description | Default_Value | 25 | |----------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------- | 26 | | Values.image.repository | The SQL image to be downloaded and used for container deployment. | mcr.microsoft.com/mssql/server | 27 | | Values.image.tag | The tag of the image to be download for the specific SQL image. | 2019-latest | 28 | | Values.ACCEPT_EULA.value | Set the ACCEPT_EULA variable to any value to confirm your acceptance of the SQL Server EULA, please refer environment variable for more details. | Y | 29 | | Values.MSSQL_PID.value | Set the SQL Server edition or product key. please refer environment variable for more details | Developer | 30 | | Values.MSSQL_AGENT_ENABLED.value | Enable SQL Server Agent. For example, 'true' is enabled and 'false' is disabled. By default, agent is disabled. please refer environment variable for more details. | TRUE | 31 | | Values.containers.ports.containerPort | Port on which the SQL Server is listening inside the container. | 1433 | 32 | | Values.podSecurityContext.fsgroup | Security context at the pod level. | 10001 | 33 | | Values.service.port | The service port number. | 1433 | 34 | | Values.replicas | This value controls the number of SQL Server deployments that would be done, consider this as the number of SQL Server instances that will run. | 3 | 35 | 36 |
37 | 38 | ## Deployment details: 39 | 40 | > [!NOTE] 41 | > Here are my deployment details, please make changes to the values.yaml or other files as per your requirement. 42 | 43 |
44 | 45 | In this scenario, I am deploying three SQL Server containers on a Azure Kubernetes Service (AKS) as statefulset deployments. You can follow [Setup and connect to AKS](https://docs.microsoft.com/en-us/azure/aks/kubernetes-walkthrough-portal) to read instructions on setting up AKS and connecting to it. Also the storage class that I am using here is "Azure-disk". Please do find details below for each of the yaml file used in the template folder of this chart. 46 | 47 | | File Name | Description | 48 | |-|-| 49 | | _helpers.tpl | Template file with all the template definitions that will be used in this chart. | 50 | | deployment.yaml | A manifest file to describing the deployment details for SQL Server. | 51 | | mssqlconfig.yaml | SQL server mssql.conf file and its content that you would like to mount to the SQL Server container. For parameters that you can pass in this file please refer mssql.conf documentation. To modify the mssql.conf settings please modify this file. | 52 | | sc.yaml | A manifest file that describes the storage class (SC) to be deployed. To make any changes to the sc please modify this file accordingly. | 53 | | service.yaml | A manifest file that defines the kubernetes service type and port. Because this is a statefulset deployment, this manifest files helps in creating the headless service. Please modify this for any service modification that is needed. | 54 | 55 |
56 | 57 | With this information, and probably after you have modified the required files you are now ready to deploy SQL Server using this chart. From the client machine where you have the helm chart installed, change the 58 | directory of the CLI to the directory where you have the chart downloaded and to deploy SQL Server using this chart run the command: 59 |
60 | 61 | 62 | ``` bash 63 | helm install mssql . --set ACCEPT_EULA.value=Y --set MSSQL_PID.value=Developer 64 | ``` 65 |
66 | 67 | After a few minutes this should deploy the SQL Server containers and you can see all the artifacts using the command : 68 |
69 | 70 | ```bash 71 | D:\helm-charts\sql-statefull-deploy>kubectl get all 72 | ``` 73 | 74 | The output should look as shown below: 75 | 76 |
77 | 78 | ```bash 79 | NAME READY STATUS RESTARTS AGE 80 | pod/mssql-sql-statefull-deploy-0 1/1 Running 0 12m 81 | pod/mssql-sql-statefull-deploy-1 1/1 Running 0 12m 82 | pod/mssql-sql-statefull-deploy-2 1/1 Running 0 12m 83 | 84 | NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE 85 | service/mssql-sql-statefull-deploy ClusterIP None 1433/TCP 16m 86 | 87 | NAME READY AGE 88 | statefulset.apps/mssql-sql-statefull-deploy 3/3 16m 89 | ``` 90 | 91 | This chart also includes an extra folder called "services" this folder has two more manifest files as described below: 92 | 93 | | Name | Description | 94 | |------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 95 | | ex_service.yaml | This containes sample code to create the external load balancer service for each of the pods created above, so SQL Server can be accessed outside the cluster | 96 | | ag_endpoint.yaml | This containes sample code to expose the AG endpoint ports within the cluster, so each pod can talk to one another on the AG port. This will be needed if you are setting up AG between the pods. | 97 | 98 |
99 | 100 | Once you deploy the above files as well, using the commands shown below, you should have an external load balancer service created for each of the pods and another cluster IP service for each of the pod exposing the AG (alwayson) port for each pod within the cluster. 101 | 102 | 103 | ```bash 104 | D:\helm-charts\sql-statefull-deploy>kubectl apply -f "D:\helm-charts\sql-statefull-deploy\services\ex_service.yaml" 105 | D:\helm-charts\sql-statefull-deploy>kubectl apply -f "D:\helm-charts\sql-statefull-deploy\services\ag_endpoint.yaml" 106 | ``` 107 | 108 | 109 | Finally, after all the deployments here are the resources that you should see: 110 | 111 | 112 | ```bash 113 | D:\>kubectl get all 114 | NAME READY STATUS RESTARTS AGE 115 | pod/mssql-sql-statefull-deploy-0 1/1 Running 0 127m 116 | pod/mssql-sql-statefull-deploy-1 1/1 Running 0 126m 117 | pod/mssql-sql-statefull-deploy-2 1/1 Running 0 125m 118 | 119 | NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE 120 | service/kubernetes ClusterIP 10.0.0.1 443/TCP 220d 121 | service/mssql-mirror-0 ClusterIP 10.0.148.0 5022/TCP 124m 122 | service/mssql-mirror-1 ClusterIP 10.0.254.58 5022/TCP 124m 123 | service/mssql-mirror-2 ClusterIP 10.0.196.129 5022/TCP 124m 124 | service/mssql-sql-statefull-deploy ClusterIP None 1433/TCP 127m 125 | service/mssql-sql-statefull-deploy-0 LoadBalancer 10.0.238.203 104.211.231.206 1433:30923/TCP 124m 126 | service/mssql-sql-statefull-deploy-1 LoadBalancer 10.0.96.108 104.211.203.78 1433:32695/TCP 124m 127 | service/mssql-sql-statefull-deploy-2 LoadBalancer 10.0.78.10 104.211.203.159 1433:31042/TCP 124m 128 | 129 | NAME READY AGE 130 | statefulset.apps/mssql-sql-statefull-deploy 3/3 127m 131 | ``` 132 | 133 | ## Connect to SQL Server 134 | 135 | Now you are ready to connect to the SQL Server using any of the familiar tools that you work with, like the [SSMS](https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver15) (SQL Server Management Studio) or [SQLCMD](https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-ver15) or [ADS](https://docs.microsoft.com/en-us/sql/azure-data-studio/download-azure-data-studio?view=sql-server-ver15) (Azure Data Studio), etc. The IP address that you will use to connect is the External-IP address for the pod service which in this case one such example is: to connect to mssql-sql-statefull-deploy-0 SQL Server, the IP address 104.211.231.206 will be used in ssms or any other client. 136 | 137 | For more details on the SQL Server deployment on AKS using manual method please refer [Deploy a SQL Server container in Kubernetes with Azure Kubernetes Services (AKS)](https://docs.microsoft.com/en-us/sql/linux/tutorial-sql-server-containers-kubernetes?view=sql-server-ver15). 138 | -------------------------------------------------------------------------------- /linux/sample-helm-chart-statefulset-deployment/services/Ag_endpoint.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: mssql-mirror-0 5 | spec: 6 | selector: 7 | statefulset.kubernetes.io/pod-name: mssql-sql-statefull-deploy-0 8 | ports: 9 | - protocol: TCP 10 | port: 5022 11 | targetPort: 5022 12 | --- 13 | apiVersion: v1 14 | kind: Service 15 | metadata: 16 | name: mssql-mirror-1 17 | spec: 18 | selector: 19 | statefulset.kubernetes.io/pod-name: mssql-sql-statefull-deploy-1 20 | ports: 21 | - protocol: TCP 22 | port: 5022 23 | targetPort: 5022 24 | --- 25 | apiVersion: v1 26 | kind: Service 27 | metadata: 28 | name: mssql-mirror-2 29 | spec: 30 | selector: 31 | statefulset.kubernetes.io/pod-name: mssql-sql-statefull-deploy-2 32 | ports: 33 | - protocol: TCP 34 | port: 5022 35 | targetPort: 5022 36 | -------------------------------------------------------------------------------- /linux/sample-helm-chart-statefulset-deployment/services/ex_service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: mssql-sql-statefull-deploy-0 5 | spec: 6 | type: LoadBalancer 7 | externalTrafficPolicy: Local 8 | selector: 9 | statefulset.kubernetes.io/pod-name: mssql-sql-statefull-deploy-0 10 | ports: 11 | - protocol: TCP 12 | port: 1433 13 | targetPort: 1433 14 | --- 15 | apiVersion: v1 16 | kind: Service 17 | metadata: 18 | name: mssql-sql-statefull-deploy-1 19 | spec: 20 | type: LoadBalancer 21 | externalTrafficPolicy: Local 22 | selector: 23 | statefulset.kubernetes.io/pod-name: mssql-sql-statefull-deploy-1 24 | ports: 25 | - protocol: TCP 26 | port: 1433 27 | targetPort: 1433 28 | --- 29 | apiVersion: v1 30 | kind: Service 31 | metadata: 32 | name: mssql-sql-statefull-deploy-2 33 | spec: 34 | type: LoadBalancer 35 | externalTrafficPolicy: Local 36 | selector: 37 | statefulset.kubernetes.io/pod-name: mssql-sql-statefull-deploy-2 38 | ports: 39 | - protocol: TCP 40 | port: 1433 41 | targetPort: 1433 42 | -------------------------------------------------------------------------------- /linux/sample-helm-chart-statefulset-deployment/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* 2 | Expand the name of the chart. 3 | */}} 4 | {{- define "sql-statefull-deploy.name" -}} 5 | {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} 6 | {{- end }} 7 | 8 | {{/* 9 | Create a default fully qualified app name. 10 | We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). 11 | If release name contains chart name it will be used as a full name. 12 | */}} 13 | {{- define "sql-statefull-deploy.fullname" -}} 14 | {{- if .Values.fullnameOverride }} 15 | {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} 16 | {{- else }} 17 | {{- $name := default .Chart.Name .Values.nameOverride }} 18 | {{- if contains $name .Release.Name }} 19 | {{- .Release.Name | trunc 63 | trimSuffix "-" }} 20 | {{- else }} 21 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} 22 | {{- end }} 23 | {{- end }} 24 | {{- end }} 25 | 26 | {{/* 27 | Create chart name and version as used by the chart label. 28 | */}} 29 | {{- define "sql-statefull-deploy.chart" -}} 30 | {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} 31 | {{- end }} 32 | 33 | {{/* 34 | Common labels 35 | */}} 36 | {{- define "sql-statefull-deploy.labels" -}} 37 | helm.sh/chart: {{ include "sql-statefull-deploy.chart" . }} 38 | {{ include "sql-statefull-deploy.selectorLabels" . }} 39 | {{- if .Chart.AppVersion }} 40 | app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} 41 | {{- end }} 42 | app.kubernetes.io/managed-by: {{ .Release.Service }} 43 | {{- end }} 44 | 45 | {{/* 46 | Selector labels 47 | */}} 48 | {{- define "sql-statefull-deploy.selectorLabels" -}} 49 | app.kubernetes.io/name: {{ include "sql-statefull-deploy.name" . }} 50 | app.kubernetes.io/instance: {{ .Release.Name }} 51 | {{- end }} 52 | 53 | {{/* 54 | Create the name of the service account to use 55 | */}} 56 | {{- define "sql-statefull-deploy.serviceAccountName" -}} 57 | {{- if .Values.serviceAccount.create }} 58 | {{- default (include "sql-statefull-deploy.fullname" .) .Values.serviceAccount.name }} 59 | {{- else }} 60 | {{- default "default" .Values.serviceAccount.name }} 61 | {{- end }} 62 | {{- end }} 63 | -------------------------------------------------------------------------------- /linux/sample-helm-chart-statefulset-deployment/templates/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: StatefulSet 3 | metadata: 4 | name: {{ include "sql-statefull-deploy.fullname" . }} 5 | labels: 6 | {{- include "sql-statefull-deploy.labels" . | nindent 4 }} 7 | spec: 8 | serviceName: {{ include "sql-statefull-deploy.fullname" . }} 9 | replicas: {{ .Values.replicas }} 10 | selector: 11 | matchLabels: 12 | {{- include "sql-statefull-deploy.selectorLabels" . | nindent 6 }} 13 | template: 14 | metadata: 15 | {{- with .Values.podAnnotations }} 16 | annotations: 17 | {{- toYaml . | nindent 8 }} 18 | {{- end }} 19 | labels: 20 | {{- include "sql-statefull-deploy.selectorLabels" . | nindent 8 }} 21 | spec: 22 | securityContext: 23 | {{- toYaml .Values.podSecurityContext | nindent 8 }} 24 | containers: 25 | - name: {{ .Chart.Name }} 26 | command: 27 | - /bin/bash 28 | - -c 29 | - cp /var/opt/config/mssql.conf /var/opt/mssql/mssql.conf && /opt/mssql/bin/sqlservr 30 | image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" 31 | imagePullPolicy: {{ .Values.image.pullPolicy }} 32 | ports: 33 | - containerPort: {{ .Values.containers.ports.containerPort}} 34 | env: 35 | - name: MSSQL_PID 36 | value: "{{ .Values.MSSQL_PID.value}}" 37 | - name: ACCEPT_EULA 38 | value: "{{ .Values.ACCEPT_EULA.value | upper}}" 39 | - name: MSSQL_AGENT_ENABLED 40 | value: "{{ .Values.MSSQL_AGENT_ENABLED.value}}" 41 | - name: SA_PASSWORD 42 | valueFrom: 43 | secretKeyRef: 44 | name: mssql 45 | key: SA_PASSWORD 46 | volumeMounts: 47 | - name: mssql 48 | mountPath: "/var/opt/mssql" 49 | - name: mssql-config-volume 50 | mountPath: /var/opt/config 51 | volumes: 52 | - name: mssql-config-volume 53 | configMap: 54 | name: mssql 55 | volumeClaimTemplates: 56 | - metadata: 57 | name: mssql 58 | spec: 59 | accessModes: 60 | - ReadWriteOnce 61 | resources: 62 | requests: 63 | storage: 8Gi -------------------------------------------------------------------------------- /linux/sample-helm-chart-statefulset-deployment/templates/mssqlconfig.yaml: -------------------------------------------------------------------------------- 1 | kind: ConfigMap 2 | apiVersion: v1 3 | metadata: 4 | name: mssql 5 | data: 6 | mssql.conf: | 7 | [EULA] 8 | accepteula = Y 9 | accepteulaml = Y 10 | 11 | [coredump] 12 | captureminiandfull = true 13 | coredumptype = full 14 | 15 | [hadr] 16 | hadrenabled = 1 17 | 18 | [language] 19 | lcid = 1033 20 | -------------------------------------------------------------------------------- /linux/sample-helm-chart-statefulset-deployment/templates/sc.yaml: -------------------------------------------------------------------------------- 1 | kind: StorageClass 2 | apiVersion: storage.k8s.io/v1beta1 3 | metadata: 4 | name: azure-disk 5 | provisioner: kubernetes.io/azure-disk 6 | parameters: 7 | storageaccounttype: Standard_LRS 8 | kind: Managed -------------------------------------------------------------------------------- /linux/sample-helm-chart-statefulset-deployment/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ include "sql-statefull-deploy.fullname" . }} 5 | labels: 6 | {{- include "sql-statefull-deploy.labels" . | nindent 4 }} 7 | spec: 8 | clusterIP: None 9 | ports: 10 | - port: {{ .Values.service.port }} 11 | targetPort: http 12 | protocol: TCP 13 | selector: 14 | {{- include "sql-statefull-deploy.selectorLabels" . | nindent 4 }} 15 | -------------------------------------------------------------------------------- /linux/sample-helm-chart-statefulset-deployment/values.yaml: -------------------------------------------------------------------------------- 1 | # Default values for mssql-latest. 2 | # This is a YAML-formatted file. 3 | # Declare variables to be passed into your templates. 4 | 5 | replicas: 3 6 | 7 | image: 8 | repository: mcr.microsoft.com/mssql/server 9 | pullPolicy: IfNotPresent 10 | # Overrides the image tag whose default is the chart appVersion. 11 | tag: "2019-latest" 12 | 13 | ACCEPT_EULA: 14 | value: "y" 15 | MSSQL_PID: 16 | value: "Developer" 17 | MSSQL_AGENT_ENABLED: 18 | value: "false" 19 | 20 | containers: 21 | ports: 22 | containerPort: 1433 23 | 24 | podAnnotations: {} 25 | 26 | podSecurityContext: 27 | fsGroup: 10001 28 | 29 | service: 30 | port: 1433 -------------------------------------------------------------------------------- /linux/sample-helm-chart/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | name: mssql-latest 3 | description: A Helm chart for Kubernetes 4 | 5 | # A chart can be either an 'application' or a 'library' chart. 6 | # 7 | # Application charts are a collection of templates that can be packaged into versioned archives 8 | # to be deployed. 9 | # 10 | # Library charts provide useful utilities or functions for the chart developer. They're included as 11 | # a dependency of application charts to inject those utilities and functions into the rendering 12 | # pipeline. Library charts do not define any templates and therefore cannot be deployed. 13 | type: application 14 | 15 | # This is the chart version. This version number should be incremented each time you make changes 16 | # to the chart and its templates, including the app version. 17 | # Versions are expected to follow Semantic Versioning (https://semver.org/) 18 | version: 0.1.1 19 | 20 | # This is the version number of the application being deployed. This version number should be 21 | # incremented each time you make changes to the application. Versions are not expected to 22 | # follow Semantic Versioning. They should reflect the version the application is using. 23 | appVersion: 1.16.0 24 | 25 | annotations: 26 | catalog.cattle.io/hidden: "true" # hide from Rancher catalog 27 | -------------------------------------------------------------------------------- /linux/sample-helm-chart/readme.md: -------------------------------------------------------------------------------- 1 | # Readme.md 2 | 3 | This HELM chart is a sample "as-is" chart provided for reference to help guide with SQL Server deployment on Kubernetes cluster. 4 | 5 | ## Prerequisites: 6 | 7 | 1. This chart is built on helm v3. It requires a kubernetes cluster to be running for you to deploy SQL container using this chart. 8 | 2. Ensure you have the helm installed on the client from where you will connect to the kubernetes cluster to deploy using the helm chart. 9 | 3. For minimum hardware requirement for the host to run SQL Server containers please refer to the system requirements section for SQL on Linux. 10 | 4. Requires the following variables to be set or changed in the values.yaml file :
11 | a. Please ensure that you accept the EULA for SQL Server, by changing the value of ACCEPT_EULA.value=y in values.yaml file or set it during the helm install command --set ACCEPT_EULA.value=Y.
12 | b. Please do choose the right edition of SQL Server that you would like to install you can change the value of the MSSQL_PID.value in the values file to the edition that you want to install or you can also 13 | change it during the helm install command using the option --set MSSQL_PID.value=Enterprise, If you do not pass the flag and do not change it in the yaml, then by default it is going to install developer edition.
c. Also please do provide your customized value for the sa_password, if you do not provide it then by default the sa_password will the value as shown in the below table.
14 | 15 | Note: Once you deploy SQL server containers using the chart below, please log into SQL Server using sa account and change the password as mentioned here, this ensures that as DBA you have the control of the sa user and password. 16 | 17 | 18 | ## Chart usage: 19 | 20 | On the client machine where you have the Helm tools installed, download the chart on your machine and make the required changes to the values.yaml file as per your requirement. To see the list of settings that can be changed using the values.yaml file please refer to the table below. 21 | 22 | | Configuration parameters | Description | Default_Value | 23 | |----------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------| 24 | | Values.image.repository | The SQL image to be downloaded and used for container deployment. | mcr.microsoft.com/mssql/server | 25 | | Values.image.tag | The tag of the image to be download for the specific SQL image. | 2019-latest | 26 | | Values.ACCEPT_EULA.value | Set the ACCEPT_EULA variable to any value to confirm your acceptance of the SQL Server EULA, please refer environment variable for more details. | Y | 27 | | Values.MSSQL_PID.value | Set the SQL Server edition or product key. please refer environment variable for more details | Developer | 28 | | Values.MSSQL_AGENT_ENABLED.value | Enable SQL Server Agent. For example, 'true' is enabled and 'false' is disabled. By default, agent is disabled. please refer environment variable for more details. | TRUE | 29 | | Values.hostname | The name that you would like to see when you run the select @@servername for the SQL instance running inside the container. | mssqllatest | 30 | | Values.sa_password | Configure the SA user password. | StrongPass1! | 31 | | Values.containers.ports.containerPort | Port on which the SQL Server is listening inside the container. | 1433 | 32 | | Values.podSecurityContext.fsgroup | Security context at the pod level. | 10001 | 33 | | Values.service.type | The type of the service to be created within the kubernetes cluster. | LoadBalancer | 34 | | Values.service.port | The service port number. | 1433 | 35 | | Values.pvc.StorageClass | The storage class to be used by the kubernetes cluster for SQL Server deployment. | azure-disk | 36 | | Values.pvc.userdbaccessMode | The access mode for the pvc (persistance volume claim) to be used by user databases. | ReadWriteOnce | 37 | | Values.pvc.userdbsize | The size to allocate to the persistance volume claim (pvc). | 5Gi | 38 | | Values.pvc.userlogaccessMode | The access mode for the pvc (persistance volume claim) to be used by the log files of the user databases. | ReadWriteOnce | 39 | | Values.pvc.userlogsize | The size to allocate to the persistance volume claim (pvc) used by the log files of the user databases. | 5Gi | 40 | | Values.pvc.tempdbaccessMode | The access mode for the pvc (persistance volume claim) to be used by temp database. | ReadWriteOnce | 41 | | Values.pvc. Tempsize | The size to allocate to the persistance volume claim (pvc) used by the temp database. | 2Gi | 42 | | Values.pvc.mssqldataaccessMode | The access mode for the pvc (persistance volume claim) to be used by system databases. | ReadWriteOnce | 43 | | Values.pvc.mssqldbsize | The size to allocate to the persistance volume claim (pvc) used by the system databases | 2Gi | 44 | 45 | 46 | 47 | ## Deployment details: 48 | 49 | > [!NOTE] 50 | > Here are my deployment details, please make changes to the values.yaml or other files as per your requirement. 51 | 52 | In this scenario, I am deploying SQL Server containers on a Azure Kubernetes Service (AKS). You can follow Setup and connect to AKS documentation to read instructions on setup and connections. Also the storage class that I am using here is "Azure-disk". Please do find details below for each of the yaml file used in the template folder of this chart. 53 | 54 | | File Name | Description | 55 | |-|-| 56 | | _helpers.tpl | Template file with all the template definitions that will be used in this chart. | 57 | | deployment.yaml | A manifest file to describing the deployment details for SQL Server. | 58 | | mssqlconfig.yaml | SQL server mssql.conf file and its content that you would like to mount to the SQL Server container. For parameters that you can pass in this file please refer mssql.conf documentation. To modify the mssql.conf settings please modify this file. | 59 | | pvc.yaml | A manifest file that describes the storage class (SC), Persistent volume (PV) and Persistent volume claims (pvc). This will be mounted to the SQL Container and referenced by the deployment.yaml. To make any changes to the sc,pv or pvc please modify this file accordingly. | 60 | | secret.yaml | A manifest file to create secrets to manage the sa_password that will be used to login to the SQL Server container that is deployed. Please modify the value.yaml file to provide your custom sa_password that you will use to login into the SQL Server once deployed. As a security measure please ensure that you change the sa_password once you login to the SQL Server for the first time. | 61 | | service.yaml | A manifest file that defines the kubernetes service type and port. Please modify this for any service modification that is needed. | 62 | 63 | With this information, and probably after you have modified the required files you are now ready to deploy SQL Server using this chart. From the client machine where you have the helm chart installed, change the 64 | directory of the CLI to the directory where you have the chart downloaded and to deploy SQL Server using this chart run the command: 65 | 66 | 67 | ``` bash 68 | helm install mssql-latest-deploy . --set ACCEPT_EULA.value=Y --set MSSQL_PID.value=Developer 69 | ``` 70 | 71 | 72 | After a few seconds this should deploy the SQL Server containers and you can see all the artifacts using the command : 73 | 74 | ```bash 75 | D:\helm-charts\mssql-latest\mssql-latest>kubectl get all 76 | ``` 77 | 78 | The output should look as shown below: 79 | 80 | ```bash 81 | NAME READY STATUS RESTARTS AGE 82 | pod/mssql-latest-deploy-645c4dddd8-647zk 1/1 Running 4 23h 83 | 84 | NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE 85 | service/kubernetes ClusterIP 10.0.0.1 443/TCP 140d 86 | service/mssql-latest-deploy LoadBalancer 10.0.57.19 20.44.43.212 1433:30544/TCP 23h 87 | 88 | NAME READY UP-TO-DATE AVAILABLE AGE 89 | deployment.apps/mssql-latest-deploy 1/1 1 1 23h 90 | 91 | NAME DESIRED CURRENT READY AGE 92 | replicaset.apps/mssql-latest-deploy-645c4dddd8 1 1 1 23h 93 | ``` 94 | 95 | ## Connect to SQL Server 96 | 97 | Now you are ready to connect to the SQL Server using any of the familiar tools that you work with, like the [SSMS](https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver15) (SQL Server Management Studio) or [SQLCMD](https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-ver15) or [ADS](https://docs.microsoft.com/en-us/sql/azure-data-studio/download-azure-data-studio?view=sql-server-ver15) (Azure Data Studio), etc. The IP address that you will use to connect is the External-IP address for the mssql-latest-deploy service which in this case is 20.44.43.212 that will be used to connect to SQL Server. 98 | 99 | For more details on the SQL Server deployment on AKS using manual method please refer [Deploy a SQL Server container in Kubernetes with Azure Kubernetes Services (AKS)](https://docs.microsoft.com/en-us/sql/linux/tutorial-sql-server-containers-kubernetes?view=sql-server-ver15). 100 | -------------------------------------------------------------------------------- /linux/sample-helm-chart/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* 2 | Expand the name of the chart. 3 | */}} 4 | {{- define "mssql-latest.name" -}} 5 | {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} 6 | {{- end }} 7 | 8 | {{/* 9 | Create a default fully qualified app name. 10 | We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). 11 | If release name contains chart name it will be used as a full name. 12 | */}} 13 | {{- define "mssql-latest.fullname" -}} 14 | {{- if .Values.fullnameOverride }} 15 | {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} 16 | {{- else }} 17 | {{- $name := default .Chart.Name .Values.nameOverride }} 18 | {{- if contains $name .Release.Name }} 19 | {{- .Release.Name | trunc 63 | trimSuffix "-" }} 20 | {{- else }} 21 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} 22 | {{- end }} 23 | {{- end }} 24 | {{- end }} 25 | 26 | {{/* 27 | Create chart name and version as used by the chart label. 28 | */}} 29 | {{- define "mssql-latest.chart" -}} 30 | {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} 31 | {{- end }} 32 | 33 | {{/* 34 | Common labels 35 | */}} 36 | {{- define "mssql-latest.labels" -}} 37 | helm.sh/chart: {{ include "mssql-latest.chart" . }} 38 | {{ include "mssql-latest.selectorLabels" . }} 39 | {{- if .Chart.AppVersion }} 40 | app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} 41 | {{- end }} 42 | app.kubernetes.io/managed-by: {{ .Release.Service }} 43 | {{- end }} 44 | 45 | {{/* 46 | Selector labels 47 | */}} 48 | {{- define "mssql-latest.selectorLabels" -}} 49 | app.kubernetes.io/name: {{ include "mssql-latest.name" . }} 50 | app.kubernetes.io/instance: {{ .Release.Name }} 51 | {{- end }} 52 | 53 | {{/* 54 | Create the name of the service account to use 55 | */}} 56 | {{- define "mssql-latest.serviceAccountName" -}} 57 | {{- if .Values.serviceAccount.create }} 58 | {{- default (include "mssql-latest.fullname" .) .Values.serviceAccount.name }} 59 | {{- else }} 60 | {{- default "default" .Values.serviceAccount.name }} 61 | {{- end }} 62 | {{- end }} 63 | 64 | 65 | {{/* 66 | Create the name for the SA password secret key. 67 | */}} 68 | {{- define "mssql.sapassword" -}} 69 | sa_password 70 | {{- end -}} 71 | -------------------------------------------------------------------------------- /linux/sample-helm-chart/templates/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: {{ include "mssql-latest.fullname" . }} 5 | labels: 6 | {{- include "mssql-latest.labels" . | nindent 4 }} 7 | spec: 8 | replicas: {{ .Values.replicas}} 9 | selector: 10 | matchLabels: 11 | {{- include "mssql-latest.selectorLabels" . | nindent 6 }} 12 | template: 13 | metadata: 14 | {{- with .Values.podAnnotations }} 15 | annotations: 16 | {{- toYaml . | nindent 8 }} 17 | {{- end }} 18 | labels: 19 | {{- include "mssql-latest.selectorLabels" . | nindent 8 }} 20 | spec: 21 | hostname: {{ .Values.hostname}} 22 | securityContext: 23 | {{- toYaml .Values.podSecurityContext | nindent 8 }} 24 | containers: 25 | - name: {{ .Chart.Name }} 26 | command: 27 | - /bin/bash 28 | - -c 29 | - cp /var/opt/config/mssql.conf /var/opt/mssql/mssql.conf && /opt/mssql/bin/sqlservr 30 | image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" 31 | imagePullPolicy: {{ .Values.image.pullPolicy }} 32 | ports: 33 | - containerPort: {{ .Values.containers.ports.containerPort}} 34 | env: 35 | - name: MSSQL_PID 36 | value: "{{ .Values.MSSQL_PID.value}}" 37 | - name: ACCEPT_EULA 38 | value: "{{ .Values.ACCEPT_EULA.value | upper}}" 39 | - name: MSSQL_AGENT_ENABLED 40 | value: "{{ .Values.MSSQL_AGENT_ENABLED.value}}" 41 | - name: SA_PASSWORD 42 | valueFrom: 43 | secretKeyRef: 44 | name: mssql-secret 45 | key: {{ template "mssql.sapassword" . }} 46 | volumeMounts: 47 | - name: mssqldb 48 | mountPath: /var/opt/mssql 49 | - name: mssqluserdb 50 | mountPath: /var/opt/mssql/userdata 51 | - name: mssqllog 52 | mountPath: /var/opt/mssql/userlog 53 | - name: mssqltemp 54 | mountPath: /var/opt/mssql/tempdb 55 | - name: mssql-config-volume 56 | mountPath: /var/opt/config 57 | volumes: 58 | - name: mssqldb 59 | persistentVolumeClaim: 60 | claimName: mssql-data 61 | - name: mssqluserdb 62 | persistentVolumeClaim: 63 | claimName: mssql-userdb 64 | - name: mssqllog 65 | persistentVolumeClaim: 66 | claimName: mssql-log 67 | - name: mssqltemp 68 | persistentVolumeClaim: 69 | claimName: mssql-temp 70 | - name: mssql-config-volume 71 | configMap: 72 | name: mssql-config -------------------------------------------------------------------------------- /linux/sample-helm-chart/templates/mssqlconfig.yaml: -------------------------------------------------------------------------------- 1 | kind: ConfigMap 2 | apiVersion: v1 3 | metadata: 4 | name: mssql-config 5 | data: 6 | mssql.conf: | 7 | [EULA] 8 | accepteula = Y 9 | accepteulaml = Y 10 | 11 | [coredump] 12 | captureminiandfull = true 13 | coredumptype = full 14 | 15 | [hadr] 16 | hadrenabled = 1 17 | 18 | [language] 19 | lcid = 1033 20 | 21 | [filelocation] 22 | defaultdatadir = /var/opt/mssql/userdata 23 | defaultlogdir = /var/opt/mssql/userlog -------------------------------------------------------------------------------- /linux/sample-helm-chart/templates/pvc.yaml: -------------------------------------------------------------------------------- 1 | kind: StorageClass 2 | apiVersion: storage.k8s.io/v1 3 | metadata: 4 | name: azure-disk 5 | provisioner: kubernetes.io/azure-disk 6 | parameters: 7 | storageaccounttype: Standard_LRS 8 | kind: Managed 9 | --- 10 | kind: PersistentVolumeClaim 11 | apiVersion: v1 12 | metadata: 13 | name: mssql-data 14 | annotations: 15 | volume.beta.kubernetes.io/storage-class: {{ .Values.pvc.StorageClass | quote }} 16 | spec: 17 | accessModes: 18 | - {{ .Values.pvc.mssqldataaccessMode | quote}} 19 | resources: 20 | requests: 21 | storage: {{ .Values.pvc.mssqldbsize}} 22 | --- 23 | kind: PersistentVolumeClaim 24 | apiVersion: v1 25 | metadata: 26 | name: mssql-userdb 27 | annotations: 28 | volume.beta.kubernetes.io/storage-class: {{ .Values.pvc.StorageClass}} 29 | spec: 30 | accessModes: 31 | - {{ .Values.pvc.userdbaccessMode | quote}} 32 | resources: 33 | requests: 34 | storage: {{ .Values.pvc.userdbsize}} 35 | --- 36 | kind: PersistentVolumeClaim 37 | apiVersion: v1 38 | metadata: 39 | name: mssql-log 40 | annotations: 41 | volume.beta.kubernetes.io/storage-class: {{ .Values.pvc.StorageClass}} 42 | spec: 43 | accessModes: 44 | - {{ .Values.pvc.userlogaccessMode | quote}} 45 | resources: 46 | requests: 47 | storage: {{ .Values.pvc.userlogsize}} 48 | --- 49 | kind: PersistentVolumeClaim 50 | apiVersion: v1 51 | metadata: 52 | name: mssql-temp 53 | annotations: 54 | volume.beta.kubernetes.io/storage-class: {{ .Values.pvc.StorageClass}} 55 | spec: 56 | accessModes: 57 | - {{ .Values.pvc.tempdbaccessMode | quote}} 58 | resources: 59 | requests: 60 | storage: {{ .Values.pvc.tempsize}} -------------------------------------------------------------------------------- /linux/sample-helm-chart/templates/secret.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: mssql-secret 5 | labels: 6 | {{- include "mssql-latest.labels" . | nindent 4 }} 7 | type: Opaque 8 | data: 9 | sa_password : {{ .Values.sa_password | b64enc | quote}} -------------------------------------------------------------------------------- /linux/sample-helm-chart/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ include "mssql-latest.fullname" . }} 5 | labels: 6 | {{- include "mssql-latest.labels" . | nindent 4 }} 7 | spec: 8 | type: {{ .Values.service.type }} 9 | ports: 10 | - port: {{ .Values.service.port }} 11 | targetPort: {{ .Values.service.port }} 12 | protocol: TCP 13 | selector: 14 | {{- include "mssql-latest.selectorLabels" . | nindent 4 }} -------------------------------------------------------------------------------- /linux/sample-helm-chart/values.yaml: -------------------------------------------------------------------------------- 1 | # Default values for mssql-latest. 2 | # This is a YAML-formatted file. 3 | # Declare variables to be passed into your templates. 4 | 5 | replicas: 1 6 | 7 | image: 8 | repository: mcr.microsoft.com/mssql/server 9 | pullPolicy: IfNotPresent 10 | # Overrides the image tag whose default is the chart appVersion. 11 | tag: "2019-latest" 12 | 13 | ACCEPT_EULA: 14 | value: "y" 15 | MSSQL_PID: 16 | value: "Developer" 17 | MSSQL_AGENT_ENABLED: 18 | value: "true" 19 | hostname: mssqllatest 20 | sa_password: "Toughpass1!" 21 | containers: 22 | ports: 23 | containerPort: 1433 24 | 25 | podAnnotations: {} 26 | 27 | podSecurityContext: 28 | fsGroup: 10001 29 | 30 | service: 31 | type: LoadBalancer 32 | port: 1433 33 | 34 | pvc: 35 | StorageClass: "azure-disk" 36 | userdbaccessMode: ReadWriteOnce 37 | userdbsize: 5Gi 38 | userlogaccessMode: ReadWriteOnce 39 | userlogsize: 5Gi 40 | tempdbaccessMode: ReadWriteOnce 41 | tempsize: 2Gi 42 | mssqldataaccessMode: ReadWriteOnce 43 | mssqldbsize: 2Gi 44 | 45 | 46 | -------------------------------------------------------------------------------- /oss-drivers/msphpsql/Dockerfile: -------------------------------------------------------------------------------- 1 | # mssql-php-msphpsql 2 | # PHP runtime with sqlservr and pdo_sqlsrv to connect to SQL Server 3 | FROM ubuntu:16.04 4 | MAINTAINER SQL Server Connectivity Team 5 | 6 | # apt-get and system utilities 7 | RUN apt-get update && apt-get install -y \ 8 | curl apt-utils apt-transport-https debconf-utils gcc build-essential g++-5\ 9 | && rm -rf /var/lib/apt/lists/* 10 | 11 | # adding custom MS repository 12 | RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - 13 | RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list 14 | 15 | # install SQL Server drivers 16 | RUN apt-get update && ACCEPT_EULA=Y apt-get install -y unixodbc-dev msodbcsql 17 | 18 | # install SQL Server tools 19 | RUN apt-get update && ACCEPT_EULA=Y apt-get install -y mssql-tools 20 | RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc 21 | RUN /bin/bash -c "source ~/.bashrc" 22 | 23 | # php libraries 24 | RUN apt-get update && apt-get install -y \ 25 | php7.0 libapache2-mod-php7.0 mcrypt php7.0-mcrypt php-mbstring php-pear php7.0-dev \ 26 | --no-install-recommends \ 27 | && rm -rf /var/lib/apt/lists/* 28 | 29 | # install necessary locales 30 | RUN apt-get install -y locales \ 31 | && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \ 32 | && locale-gen 33 | 34 | # install SQL Server PHP connector module 35 | RUN pecl install sqlsrv pdo_sqlsrv 36 | 37 | # initial configuration of SQL Server PHP connector 38 | RUN echo "extension=/usr/lib/php/20151012/sqlsrv.so" >> /etc/php/7.0/cli/php.ini 39 | RUN echo "extension=/usr/lib/php/20151012/pdo_sqlsrv.so" >> /etc/php/7.0/cli/php.ini 40 | 41 | # install additional utilities 42 | RUN apt-get update && apt-get install gettext nano vim -y 43 | 44 | # add sample code 45 | RUN mkdir /sample 46 | ADD . /sample 47 | WORKDIR /sample 48 | 49 | CMD /bin/bash ./entrypoint.sh -------------------------------------------------------------------------------- /oss-drivers/msphpsql/README.md: -------------------------------------------------------------------------------- 1 | # PHP Development Environment for SQL Server 2 | 3 | This image provides an integrated development environment for PHP with connectivity to a remote SQL Server database. Learn more about [SQL Server on Linux](https://hub.docker.com/_/microsoft-mssql-server). To report issues or provide feedback, please file an issue in the [SQL Server in Docker GitHub Repository](https://github.com/Microsoft/mssql-docker). 4 | 5 | ### [Dockerfile](https://github.com/Microsoft/mssql-docker/blob/master/oss-drivers//msphpsql/Dockerfile) 6 | 7 | The following components are included: 8 | - Ubuntu 16.04 OS layer. 9 | - Pre-configured PHP7.0 runtime environment. 10 | - [sqlsrv](http://php.net/manual/en/book.sqlsrv.php) and [pdo_sqlsrv](http://php.net/manual/en/ref.pdo-sqlsrv.php) for SQL Server. 11 | - A working PHP to SQL Server code sample. 12 | - SQL Server command-line utilities (sqlcmd and bcp). 13 | - Command-line text editor tools (nano and vim). 14 | 15 | ## Usage 16 | To run an interactive bash session in this container simply run: 17 | 18 | docker run -it microsoft/msphpsql 19 | 20 | The following optional environment variables can be provided to create the code sample: 21 | - `$DB_HOST`: The IP address or hostname where the SQL Server instance is running. 22 | - `$DB_USERNAME`: The database user in the SQL Server instance. 23 | - `$DB_PASSWORD`: The database user's password in the SQL Server instance. 24 | 25 | **Note:** If you are running SQL Server in a Docker container as well, you can obtain the container's IP address using `docker inspect `. 26 | 27 | After passing the above environment variables Within the container, you can run the following commands: 28 | - `php connect.php`: Execute the code sample to connect to SQL Server. The `connect.php` file will already have the database parameters. 29 | - `sqlcmd -S $DB_HOST -U $DB_USERNAME -P $DB_PASSWORD`: This will run the command-line client for SQL Server where you can execute T-SQL statements against it. 30 | 31 | # User Feedback 32 | --- 33 | 34 | + For issues with or questions about this image, please contact us through a [GitHub issue](https://github.com/Microsoft/mssql-docker/issues). 35 | 36 | # Further Reading 37 | --- 38 | 39 | + [SQL Server on Linux for Docker documentation](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-docker) 40 | + [SQL Server - Developer Getting Started Tutorials](https://www.microsoft.com/en-us/sql-server/developer-get-started/?utm_source=DockerHub) 41 | + [SQL Server Docker GitHub Repository](https://github.com/Microsoft/mssql-docker) 42 | -------------------------------------------------------------------------------- /oss-drivers/msphpsql/entrypoint.sh: -------------------------------------------------------------------------------- 1 | printf "\n### PHP Development Environment for SQL Server ###\n\n" 2 | 3 | printf "This container includes everything necessary to start working with PHP against SQL Server. Contents:\n\t- ODBC Drivers\n\t- msphpsql connector module.\n\t- A working PHP to SQL Server sample.\n\t- SQL Server command-line utilities.\n\nTo start an interactive shell session with this container:\n\tdocker run -it microsoft/msphpsql\n\n" 4 | 5 | if [ "$DB_HOST" ] && [ "$DB_USERNAME" ] && [ "$DB_PASSWORD" ] 6 | then 7 | printf "Provided environment variables:\n\t- Host:$DB_HOST\n\t- User:$DB_USERNAME\n\t- Password:$DB_PASSWORD\n\n" 8 | 9 | envsubst connect.php 10 | 11 | printf "Environment variables have been written in /sample/connect.php\n\n" 12 | 13 | printf "To run the sample with the provided environment variables, run from within the container:php connect.php\n\n" 14 | fi 15 | 16 | printf "To connect to SQL Server using sqlcmd, use:\n\tdocker run microsoft/msphpsql sqlcmd -S -U -P \n\n" 17 | 18 | printf "For more samples, visit: http://aka.ms/sqldev\n" 19 | 20 | /bin/bash -------------------------------------------------------------------------------- /oss-drivers/msphpsql/sample.php: -------------------------------------------------------------------------------- 1 | "", 5 | "Uid" => "$DB_USERNAME", 6 | "PWD" => "$DB_PASSWORD" 7 | ); 8 | //Establishes the connection 9 | $conn = sqlsrv_connect($serverName, $connectionOptions); 10 | if($conn){ 11 | echo "Connected!"; 12 | } 13 | else{ 14 | die( 15 | print_r(sqlsrv_errors(), true) 16 | ); 17 | } 18 | 19 | ?> -------------------------------------------------------------------------------- /oss-drivers/php-mssql/Dockerfile: -------------------------------------------------------------------------------- 1 | # php-mssql 2 | # PHP runtime with pdo_sqlsrv to connect to SQL Server 3 | FROM ubuntu:16.04 4 | 5 | # apt-get and system utilities 6 | RUN apt-get update && apt-get install -y \ 7 | curl apt-utils apt-transport-https debconf-utils gcc build-essential g++-5\ 8 | && rm -rf /var/lib/apt/lists/* 9 | 10 | # adding custom MS repository 11 | RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - 12 | RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list 13 | 14 | # install SQL Server drivers 15 | RUN apt-get update && ACCEPT_EULA=Y apt-get install -y unixodbc-dev msodbcsql 16 | 17 | # php libraries 18 | RUN apt-get update && apt-get install -y \ 19 | php7.0 libapache2-mod-php7.0 mcrypt php7.0-mcrypt php-mbstring php-pear php7.0-dev \ 20 | --no-install-recommends \ 21 | && rm -rf /var/lib/apt/lists/* 22 | 23 | # install necessary locales 24 | RUN apt-get install -y locales \ 25 | && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \ 26 | && locale-gen 27 | 28 | # install SQL Server PHP connector module 29 | RUN pecl install sqlsrv pdo_sqlsrv 30 | 31 | # initial configuration of SQL Server PHP connector 32 | RUN echo "extension=/usr/lib/php/20151012/sqlsrv.so" >> /etc/php/7.0/cli/php.ini 33 | RUN echo "extension=/usr/lib/php/20151012/pdo_sqlsrv.so" >> /etc/php/7.0/cli/php.ini 34 | -------------------------------------------------------------------------------- /oss-drivers/php-mssql/README.md: -------------------------------------------------------------------------------- 1 | # DEPRECATED. Please go to [msphpsql](https://github.com/Microsoft/mssql-docker/tree/master/oss-drivers/msphpsql) 2 | 3 | # PHP + SQL Server Runtime Environment 4 | 5 | This image provides the latest version of the PHP drivers for SQL Server on an Ubuntu base-layer. 6 | 7 | ## Contributions 8 | 9 | Feel free to contribute improvements to this image through pull requests. 10 | 11 | -------------------------------------------------------------------------------- /oss-drivers/php-mssql/connect.php: -------------------------------------------------------------------------------- 1 | "", 5 | "Uid" => "$DB_USERNAME", 6 | "PWD" => "$DB_PASSWORD" 7 | ); 8 | //Establishes the connection 9 | $conn = sqlsrv_connect($serverName, $connectionOptions); 10 | if($conn){ 11 | echo "Connected!"; 12 | } 13 | else{ 14 | die( 15 | print_r(sqlsrv_errors(), true) 16 | ); 17 | } 18 | $tsql= "SELECT @@version;"; 19 | $getResults= sqlsrv_query($conn, $tsql); 20 | if ($getResults == FALSE) 21 | die(FormatErrors(sqlsrv_errors())); 22 | while ($row = sqlsrv_fetch_array($getResults, SQLSRV_FETCH_ASSOC)) { 23 | echo ($row['Id'] . " " . $row['Name'] . " " . $row['Location'] . PHP_EOL); 24 | } 25 | 26 | 27 | ?> -------------------------------------------------------------------------------- /oss-drivers/pyodbc/Dockerfile: -------------------------------------------------------------------------------- 1 | # mssql-python-pyodbc 2 | # Python runtime with pyodbc to connect to SQL Server 3 | FROM ubuntu:16.04 4 | 5 | # apt-get and system utilities 6 | RUN apt-get update && apt-get install -y \ 7 | curl apt-utils apt-transport-https debconf-utils gcc build-essential g++-5\ 8 | && rm -rf /var/lib/apt/lists/* 9 | 10 | # adding custom MS repository 11 | RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - 12 | RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list 13 | 14 | # install SQL Server drivers 15 | RUN apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql unixodbc-dev 16 | 17 | # install SQL Server tools 18 | RUN apt-get update && ACCEPT_EULA=Y apt-get install -y mssql-tools 19 | RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc 20 | RUN /bin/bash -c "source ~/.bashrc" 21 | 22 | # python libraries 23 | RUN apt-get update && apt-get install -y \ 24 | python-pip python-dev python-setuptools \ 25 | --no-install-recommends \ 26 | && rm -rf /var/lib/apt/lists/* 27 | 28 | # install necessary locales 29 | RUN apt-get update && apt-get install -y locales \ 30 | && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \ 31 | && locale-gen 32 | RUN pip install --upgrade pip 33 | 34 | # install SQL Server Python SQL Server connector module - pyodbc 35 | RUN pip install pyodbc 36 | 37 | # install additional utilities 38 | RUN apt-get update && apt-get install gettext nano vim -y 39 | 40 | # add sample code 41 | RUN mkdir /sample 42 | ADD . /sample 43 | WORKDIR /sample 44 | 45 | CMD /bin/bash ./entrypoint.sh 46 | -------------------------------------------------------------------------------- /oss-drivers/pyodbc/README.md: -------------------------------------------------------------------------------- 1 | # Python Development Environment for SQL Server 2 | 3 | This image provides an integrated development environment for Python with connectivity to a remote SQL Server database. Learn more about [SQL Server on Linux](https://hub.docker.com/_/microsoft-mssql-server). To report issues or provide feedback, please file an issue in the [SQL Server in Docker GitHub Repository](https://github.com/Microsoft/mssql-docker). 4 | 5 | ### [Dockerfile](https://github.com/Microsoft/mssql-docker/blob/master/oss-drivers/pyodbc/Dockerfile) 6 | 7 | The following components are included: 8 | - Ubuntu 16.04 OS layer. 9 | - Pre-configured Python 2.7 runtime environment. 10 | - [pyodbc driver](https://github.com/mkleehammer/pyodbc) for SQL Server. 11 | - A working Python to SQL Server code sample. 12 | - SQL Server command-line utilities (sqlcmd and bcp). 13 | - Command-line text editor tools (nano and vim). 14 | 15 | ## Usage 16 | To run an interactive bash session in this container simply run: 17 | 18 | docker run -it microsoft/pyodbc 19 | 20 | The following optional environment variables can be provided to create the code sample: 21 | - `$DB_HOST`: The IP address or hostname where the SQL Server instance is running. 22 | - `$DB_USERNAME`: The database user in the SQL Server instance. 23 | - `$DB_PASSWORD`: The database user's password in the SQL Server instance. 24 | 25 | **Note:** If you are running SQL Server in a Docker container as well, you can obtain the container's IP address using `docker inspect `. 26 | 27 | After passing the above environment variables Within the container, you can run the following commands: 28 | - `python connect.py`: Execute the code sample to connect to SQL Server. The `connect.py` file will already have the database parameters. 29 | - `sqlcmd -S $DB_HOST -U $DB_USERNAME -P $DB_PASSWORD`: This will run the command-line client for SQL Server where you can execute T-SQL statements against it. 30 | 31 | # User Feedback 32 | --- 33 | 34 | + For issues with or questions about this image, please contact us through a [GitHub issue](https://github.com/Microsoft/mssql-docker/issues). 35 | 36 | # Further Reading 37 | --- 38 | 39 | + [SQL Server on Linux for Docker documentation](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-docker) 40 | + [SQL Server - Developer Getting Started Tutorials](https://www.microsoft.com/en-us/sql-server/developer-get-started/?utm_source=DockerHub) 41 | + [SQL Server Docker GitHub Repository](https://github.com/Microsoft/mssql-docker) 42 | 43 | -------------------------------------------------------------------------------- /oss-drivers/pyodbc/entrypoint.sh: -------------------------------------------------------------------------------- 1 | printf "\n### Python Development Environment for SQL Server ###\n\n" 2 | 3 | printf "This container includes everything necessary to start working with Python against SQL Server. Contents:\n\t- ODBC Drivers\n\t- pyodbc connector module.\n\t- A working Python to SQL Server sample.\n\t- SQL Server command-line utilities.\n\nTo start an interactive shell session with this container:\n\tdocker run -it microsoft/pyodbc\n\n" 4 | 5 | if [ "$DB_HOST" ] && [ "$DB_USERNAME" ] && [ "$DB_PASSWORD" ] 6 | then 7 | printf "Provided environment variables:\n\t- Host:$DB_HOST\n\t- User:$DB_USERNAME\n\t- Password:$DB_PASSWORD\n\n" 8 | 9 | envsubst connect.py 10 | 11 | printf "Environment variables have been written in /sample/connect.py\n\n" 12 | 13 | printf "To run the sample with the provided environment variables, run from within the container:python connect.py\n\n" 14 | fi 15 | 16 | printf "To connect to SQL Server using sqlcmd, use:\n\tdocker run microsoft/pyodbc sqlcmd -S -U -P \n\n" 17 | 18 | printf "For more samples, visit: http://aka.ms/sqldev\n" 19 | 20 | /bin/bash -------------------------------------------------------------------------------- /oss-drivers/pyodbc/sample.py: -------------------------------------------------------------------------------- 1 | import pyodbc 2 | server = '$DB_HOST' 3 | username = '$DB_USERNAME' 4 | password = '$DB_PASSWORD' 5 | 6 | cnxn = pyodbc.connect('DRIVER={ODBC Driver 13 for SQL Server};SERVER='+server+';PORT=1443;UID='+username+';PWD='+ password) 7 | cursor = cnxn.cursor() 8 | 9 | print ('Using the following SQL Server version:') 10 | tsql = "SELECT @@version;" 11 | with cursor.execute(tsql): 12 | row = cursor.fetchone() 13 | print (str(row[0])) -------------------------------------------------------------------------------- /oss-drivers/tedious/Dockerfile: -------------------------------------------------------------------------------- 1 | # mssql-nodejs-tedious 2 | # Node.js runtime with tedious to connect to SQL Server 3 | FROM ubuntu:16.04 4 | 5 | # apt-get and system utilities 6 | RUN apt-get update && apt-get install -y \ 7 | curl apt-utils apt-transport-https debconf-utils gcc build-essential g++-5\ 8 | && rm -rf /var/lib/apt/lists/* 9 | 10 | # adding custom MS repository 11 | RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - 12 | RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list 13 | 14 | # install SQL Server tools 15 | RUN apt-get update && ACCEPT_EULA=Y apt-get install -y mssql-tools 16 | RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc 17 | RUN /bin/bash -c "source ~/.bashrc" 18 | 19 | # nodejs libraries 20 | RUN apt-get update && apt-get install -y \ 21 | nodejs npm \ 22 | --no-install-recommends \ 23 | && rm -rf /var/lib/apt/lists/* 24 | 25 | # install necessary locales 26 | RUN apt-get install -y locales \ 27 | && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \ 28 | && locale-gen 29 | 30 | # install additional utilities 31 | RUN apt-get update && apt-get install gettext nano vim -y 32 | 33 | # add sample code 34 | RUN mkdir /sample 35 | ADD . /sample 36 | WORKDIR /sample 37 | 38 | # start project and install tedious 39 | RUN npm init -y 40 | RUN npm install tedious 41 | 42 | CMD /bin/bash ./entrypoint.sh -------------------------------------------------------------------------------- /oss-drivers/tedious/README.md: -------------------------------------------------------------------------------- 1 | # Node.js Development Environment for SQL Server 2 | 3 | This image provides an integrated development environment for Node.js with connectivity to a remote SQL Server database. Learn more about [SQL Server on Linux](https://hub.docker.com/_/microsoft-mssql-server). To report issues or provide feedback, please file an issue in the [SQL Server in Docker GitHub Repository](https://github.com/Microsoft/mssql-docker). 4 | 5 | ### [Dockerfile](https://github.com/Microsoft/mssql-docker/blob/master/oss-drivers/tedious/Dockerfile) 6 | 7 | The following components are included: 8 | - Ubuntu 16.04 OS layer. 9 | - Pre-configured Node.js runtime environment (nodejs + npm). 10 | - [tedious Node.js driver](https://www.npmjs.com/package/tedious) for SQL Server. 11 | - A working Node.js to SQL Server code sample. 12 | - SQL Server command-line utilities (sqlcmd and bcp). 13 | - Command-line text editor tools (nano and vim). 14 | 15 | ## Usage 16 | To run an interactive bash session in this container simply run: 17 | 18 | docker run -it microsoft/tedious 19 | 20 | The following optional environment variables can be provided to create the code sample: 21 | - `$DB_HOST`: The IP address or hostname where the SQL Server instance is running. 22 | - `$DB_USERNAME`: The database user in the SQL Server instance. 23 | - `$DB_PASSWORD`: The database user's password in the SQL Server instance. 24 | 25 | **Note:** If you are running SQL Server in a Docker container as well, you can obtain the container's IP address using `docker inspect `. 26 | 27 | After passing the above environment variables Within the container, you can run the following commands: 28 | - `node connect.js`: Execute the code sample to connect to SQL Server. The `connect.js` file will already have the database parameters. 29 | - `sqlcmd -S $DB_HOST -U $DB_USERNAME -P $DB_PASSWORD`: This will run the command-line client for SQL Server where you can execute T-SQL statements against it. 30 | 31 | # User Feedback 32 | --- 33 | 34 | + For issues with or questions about this image, please contact us through a [GitHub issue](https://github.com/Microsoft/mssql-docker/issues). 35 | 36 | # Further Reading 37 | --- 38 | 39 | + [SQL Server on Linux for Docker documentation](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-docker) 40 | + [SQL Server - Developer Getting Started Tutorials](https://www.microsoft.com/en-us/sql-server/developer-get-started/?utm_source=DockerHub) 41 | + [SQL Server Docker GitHub Repository](https://github.com/Microsoft/mssql-docker) 42 | -------------------------------------------------------------------------------- /oss-drivers/tedious/entrypoint.sh: -------------------------------------------------------------------------------- 1 | printf "\n### Node.js Development Environment for SQL Server ###\n\n" 2 | 3 | printf "This container includes everything necessary to start working with Node.js against SQL Server. Contents:\n\t- tedious connector module.\n\t- A working Node.js to SQL Server sample.\n\t- SQL Server command-line utilities.\n\nTo start an interactive shell session with this container:\n\tdocker run -it microsoft/tedious\n\n" 4 | 5 | if [ "$DB_HOST" ] && [ "$DB_USERNAME" ] && [ "$DB_PASSWORD" ] 6 | then 7 | printf "Provided environment variables:\n\t- Host:$DB_HOST\n\t- User:$DB_USERNAME\n\t- Password:$DB_PASSWORD\n\n" 8 | 9 | envsubst connect.js 10 | 11 | printf "Environment variables have been written in /sample/connect.js\n\n" 12 | 13 | printf "To run the sample with the provided environment variables, run from within the container:node connect.js\n\n" 14 | fi 15 | 16 | printf "To connect to SQL Server using sqlcmd, use:\n\tdocker run microsoft/pyodbc sqlcmd -S -U -P \n\n" 17 | 18 | printf "For more samples, visit: http://aka.ms/sqldev\n" 19 | 20 | /bin/bash -------------------------------------------------------------------------------- /oss-drivers/tedious/sample.js: -------------------------------------------------------------------------------- 1 | var Connection = require('tedious').Connection; 2 | var Request = require('tedious').Request; 3 | var TYPES = require('tedious').TYPES; 4 | 5 | // Create connection to database 6 | var config = { 7 | userName: '$DB_USERNAME', // update me 8 | password: '$DB_PASSWORD', // update me 9 | server: '$DB_HOST' 10 | } 11 | var connection = new Connection(config); 12 | 13 | // Attempt to connect and execute queries if connection goes through 14 | connection.on('connect', function(err) { 15 | if (err) { 16 | console.log(err); 17 | } else { 18 | console.log('Connected'); 19 | } 20 | }); -------------------------------------------------------------------------------- /windows/README.md: -------------------------------------------------------------------------------- 1 | ## Windows Containers 2 | This includes samples for setting up mssql-server in Windows Containers. Currently it includes the following: 3 | - __[mssql-server-windows-developer](mssql-server-windows-developer/)__ 4 | - __[mssql-server-windows-express](mssql-server-windows-express/)__ 5 | - __[mssql-server-windows](mssql-server-windows/)__ 6 | 7 | ## Note: These images are provided AS-IS. Microsoft currently does not support running SQL Server on Windows Containers in a production scenario. 8 | -------------------------------------------------------------------------------- /windows/build.ps1: -------------------------------------------------------------------------------- 1 | pushd $PSScriptRoot 2 | 3 | Get-ChildItem -Recurse -Filter dockerfile | foreach { 4 | $tag = $_.Directory.Name 5 | docker build -t $tag $_.DirectoryName 6 | } 7 | 8 | popd -------------------------------------------------------------------------------- /windows/mssql-server-windows-developer/dockerfile: -------------------------------------------------------------------------------- 1 | FROM microsoft/windowsservercore 2 | 3 | LABEL maintainer "Perry Skountrianos" 4 | 5 | # Download Links: 6 | ENV exe "https://go.microsoft.com/fwlink/?linkid=840945" 7 | ENV box "https://go.microsoft.com/fwlink/?linkid=840944" 8 | 9 | ENV sa_password="_" \ 10 | attach_dbs="[]" \ 11 | ACCEPT_EULA="_" \ 12 | sa_password_path="C:\ProgramData\Docker\secrets\sa-password" 13 | 14 | SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] 15 | 16 | # make install files accessible 17 | COPY start.ps1 / 18 | WORKDIR / 19 | 20 | RUN Invoke-WebRequest -Uri $env:box -OutFile SQL.box ; \ 21 | Invoke-WebRequest -Uri $env:exe -OutFile SQL.exe ; \ 22 | Start-Process -Wait -FilePath .\SQL.exe -ArgumentList /qs, /x:setup ; \ 23 | .\setup\setup.exe /q /ACTION=Install /INSTANCENAME=MSSQLSERVER /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT='NT AUTHORITY\NETWORK SERVICE' /SQLSYSADMINACCOUNTS='BUILTIN\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS ; \ 24 | Remove-Item -Recurse -Force SQL.exe, SQL.box, setup 25 | 26 | RUN stop-service MSSQLSERVER ; \ 27 | set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.MSSQLSERVER\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; \ 28 | set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.MSSQLSERVER\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; \ 29 | set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.MSSQLSERVER\mssqlserver\' -name LoginMode -value 2 ; 30 | 31 | HEALTHCHECK CMD [ "sqlcmd", "-Q", "select 1" ] 32 | 33 | CMD .\start -sa_password $env:sa_password -ACCEPT_EULA $env:ACCEPT_EULA -attach_dbs \"$env:attach_dbs\" -Verbose 34 | -------------------------------------------------------------------------------- /windows/mssql-server-windows-developer/dockerfile_1: -------------------------------------------------------------------------------- 1 | # SQL Server 2019 Windows container dockerfile 2 | ## Warning: Restarting windows container causes the machine key to change and hence if you have any encryption configured then restarting SQL On Windows containers 3 | ## breaks the encryption key chain in SQL Server. 4 | 5 | # Download the SQL Developer from the following location https://go.microsoft.com/fwlink/?linkid=866662 and extract the .box and .exe files using the option: "Download Media" 6 | 7 | FROM mcr.microsoft.com/windows/servercore:ltsc2019 8 | 9 | ENV sa_password="_" \ 10 | attach_dbs="[]" \ 11 | ACCEPT_EULA="_" \ 12 | sa_password_path="C:\ProgramData\Docker\secrets\sa-password" 13 | 14 | SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] 15 | 16 | # make install files accessible 17 | COPY start.ps1 / 18 | COPY SQLServer2019-DEV-x64-ENU.box / 19 | COPY SQLServer2019-DEV-x64-ENU.exe / 20 | COPY SQLServer2019-DEV-x64-ENU / 21 | 22 | WORKDIR / 23 | 24 | RUN Start-Process -Wait -FilePath .\SQLServer2019-DEV-x64-ENU.exe -ArgumentList /qs, /x:setup ; \ 25 | .\setup\setup.exe /q /ACTION=Install /INSTANCENAME=MSSQLSERVER /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT='NT AUTHORITY\NETWORK SERVICE' /SQLSYSADMINACCOUNTS='BUILTIN\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS ; \ 26 | Remove-Item -Recurse -Force SQLServer2019-DEV-x64-ENU.exe, SQLServer2019-DEV-x64-ENU.box, setup 27 | 28 | RUN stop-service MSSQLSERVER ; \ 29 | set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql15.MSSQLSERVER\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; \ 30 | set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql15.MSSQLSERVER\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; \ 31 | set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql15.MSSQLSERVER\mssqlserver\' -name LoginMode -value 2 ; 32 | 33 | HEALTHCHECK CMD [ "sqlcmd", "-Q", "select 1" ] 34 | 35 | CMD .\start -sa_password $env:sa_password -ACCEPT_EULA $env:ACCEPT_EULA -attach_dbs \"$env:attach_dbs\" -Verbose 36 | -------------------------------------------------------------------------------- /windows/mssql-server-windows-developer/readme.md: -------------------------------------------------------------------------------- 1 | # mssql-server-windows-developer 2 | This is the Dockerfile for the latest version of SQL Server Developer Edition for Windows Containers. 3 | 4 | ### Contents 5 | 6 | [About this sample](#about-this-sample)
7 | [Before you begin](#before-you-begin)
8 | [Run this sample](#run-this-sample)
9 | [Sample details](#sample-details)
10 | [Disclaimers](#disclaimers)
11 | [Related links](#related-links)
12 | 13 | 14 | 15 | ## About this sample 16 | 17 | 1. **Applies to:** SQL Server Developer Edition, Windows Server 2016, Windows 10 18 | 5. **Authors:** Perry Skountrianos [perrysk-msft] 19 | 20 | 21 | 22 | ## Before you begin 23 | 24 | To run this sample, you need the following prerequisites. 25 | 26 | **Software prerequisites:** 27 | 28 | You can run the container with the following command. 29 | (Note the you'll need Windows Server 2016 or Windows 10) 30 | 31 | ```` 32 | docker run -d -p 1433:1433 -v C:/temp/:C:/temp/ -e sa_password= -e ACCEPT_EULA=Y -e attach_dbs="" microsoft/mssql-server-windows-developer 33 | ```` 34 | 35 | - **-p HostPort:containerPort** is for port-mapping a container network port to a host port. 36 | - **-v HostPath:containerPath** is for mounting a folder from the host inside the container. 37 | 38 | This can be used for saving database outside of the container. 39 | 40 | - **-it** can be used to show the verbose output of the SQL startup script. 41 | 42 | Use this to debug the container in case of issues. 43 | 44 | 45 | 46 | ## Run this sample 47 | 48 | The image provides two environment variables to optionally set:
49 | - **accept_eula**: Confirms acceptance of the end user licensing agreement found [here](http://go.microsoft.com/fwlink/?LinkId=746388) 50 | - **sa_password**: Sets the sa password and enables the sa login 51 | - **attach_dbs**: The configuration for attaching custom DBs (.mdf, .ldf files). 52 | 53 | This should be a JSON string, in the following format (note the use of SINGLE quotes!) 54 | ``` 55 | [ 56 | { 57 | 'dbName': 'MaxDb', 58 | 'dbFiles': ['C:\\temp\\maxtest.mdf', 59 | 'C:\\temp\\maxtest_log.ldf'] 60 | }, 61 | { 62 | 'dbName': 'PerryDb', 63 | 'dbFiles': ['C:\\temp\\perrytest.mdf', 64 | 'C:\\temp\\perrytest_log.ldf'] 65 | } 66 | ] 67 | ``` 68 | 69 | This is an array of databases, which can have zero to N databases. 70 | 71 | Each consisting of: 72 | - **dbName**: The name of the database 73 | - **dbFiles**: An array of one or many absolute paths to the .MDF and .LDF files. 74 | 75 | **Note:** 76 | The path has double backslashes for escaping! 77 | The path refers to files **within the container**. So make sure to include them in the image or mount them via **-v**! 78 | 79 | 80 | This example shows all parameters in action: 81 | ``` 82 | docker run -d -p 1433:1433 -v C:/temp/:C:/temp/ -e sa_password= -e ACCEPT_EULA=Y -e attach_dbs="[{'dbName':'SampleDB','dbFiles':['C:\\temp\\sampledb.mdf','C:\\temp\\sampledb_log. 83 | ldf']}]" microsoft/mssql-server-windows-developer 84 | ``` 85 | 86 | 87 | 88 | ## Rebuild the image 89 | 90 | ``` 91 | docker build --memory 4g . 92 | ``` 93 | 94 | 95 | ## Sample details 96 | 97 | The Dockerfile downloads and installs the latest version of SQL Server Developer Edition. 98 | 99 | 100 | 101 | ## Disclaimers 102 | The code included in this sample is not intended to be a set of best practices on how to build scalable enterprise grade applications. This is beyond the scope of this quick start sample. 103 | 104 | 105 | 106 | ## Related Links 107 | 108 | 109 | For more information, see these articles: 110 | - [Windows Containers](https://msdn.microsoft.com/en-us/virtualization/windowscontainers/about/about_overview) 111 | - [Windows-based containers: Modern app development with enterprise-grade control](https://www.youtube.com/watch?v=Ryx3o0rD5lY&feature=youtu.be) 112 | - [Windows Containers: What, Why and How](https://channel9.msdn.com/Events/Build/2015/2-704) 113 | - [SQL Server in Windows Containers](https://blogs.msdn.microsoft.com/sqlserverstorageengine/2016/03/21/sql-server-in-windows-containers/#comments) 114 | -------------------------------------------------------------------------------- /windows/mssql-server-windows-developer/start.ps1: -------------------------------------------------------------------------------- 1 | # The script sets the sa password and start the SQL Service 2 | # Also it attaches additional database from the disk 3 | # The format for attach_dbs 4 | 5 | param( 6 | [Parameter(Mandatory=$false)] 7 | [string]$sa_password, 8 | 9 | [Parameter(Mandatory=$false)] 10 | [string]$ACCEPT_EULA, 11 | 12 | [Parameter(Mandatory=$false)] 13 | [string]$attach_dbs 14 | ) 15 | 16 | 17 | if($ACCEPT_EULA -ne "Y" -And $ACCEPT_EULA -ne "y") 18 | { 19 | Write-Verbose "ERROR: You must accept the End User License Agreement before this container can start." 20 | Write-Verbose "Set the environment variable ACCEPT_EULA to 'Y' if you accept the agreement." 21 | 22 | exit 1 23 | } 24 | 25 | # start the service 26 | Write-Verbose "Starting SQL Server" 27 | start-service MSSQLSERVER 28 | 29 | if($sa_password -eq "_") { 30 | if (Test-Path $env:sa_password_path) { 31 | $sa_password = Get-Content -Raw $secretPath 32 | } 33 | else { 34 | Write-Verbose "WARN: Using default SA password, secret file not found at: $secretPath" 35 | } 36 | } 37 | 38 | if($sa_password -ne "_") 39 | { 40 | Write-Verbose "Changing SA login credentials" 41 | $sqlcmd = "ALTER LOGIN sa with password=" +"'" + $sa_password + "'" + ";ALTER LOGIN sa ENABLE;" 42 | & sqlcmd -Q $sqlcmd 43 | } 44 | 45 | $attach_dbs_cleaned = $attach_dbs.TrimStart('\\').TrimEnd('\\') 46 | 47 | $dbs = $attach_dbs_cleaned | ConvertFrom-Json 48 | 49 | if ($null -ne $dbs -And $dbs.Length -gt 0) 50 | { 51 | Write-Verbose "Attaching $($dbs.Length) database(s)" 52 | 53 | Foreach($db in $dbs) 54 | { 55 | $files = @(); 56 | Foreach($file in $db.dbFiles) 57 | { 58 | $files += "(FILENAME = N'$($file)')"; 59 | } 60 | 61 | $files = $files -join "," 62 | $sqlcmd = "IF EXISTS (SELECT 1 FROM SYS.DATABASES WHERE NAME = '" + $($db.dbName) + "') BEGIN EXEC sp_detach_db [$($db.dbName)] END;CREATE DATABASE [$($db.dbName)] ON $($files) FOR ATTACH;" 63 | 64 | Write-Verbose "Invoke-Sqlcmd -Query $($sqlcmd)" 65 | & sqlcmd -Q $sqlcmd 66 | } 67 | } 68 | 69 | Write-Verbose "Started SQL Server." 70 | 71 | $lastCheck = (Get-Date).AddSeconds(-2) 72 | while ($true) 73 | { 74 | Get-EventLog -LogName Application -Source "MSSQL*" -After $lastCheck | Select-Object TimeGenerated, EntryType, Message 75 | $lastCheck = Get-Date 76 | Start-Sleep -Seconds 2 77 | } 78 | -------------------------------------------------------------------------------- /windows/mssql-server-windows-express/dockerfile: -------------------------------------------------------------------------------- 1 | FROM microsoft/windowsservercore 2 | 3 | LABEL maintainer "Perry Skountrianos" 4 | 5 | # Download Links: 6 | ENV sql_express_download_url "https://go.microsoft.com/fwlink/?linkid=829176" 7 | 8 | ENV sa_password="_" \ 9 | attach_dbs="[]" \ 10 | ACCEPT_EULA="_" \ 11 | sa_password_path="C:\ProgramData\Docker\secrets\sa-password" 12 | 13 | SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] 14 | 15 | # make install files accessible 16 | COPY start.ps1 / 17 | WORKDIR / 18 | 19 | RUN Invoke-WebRequest -Uri $env:sql_express_download_url -OutFile sqlexpress.exe ; \ 20 | Start-Process -Wait -FilePath .\sqlexpress.exe -ArgumentList /qs, /x:setup ; \ 21 | .\setup\setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT='NT AUTHORITY\System' /SQLSYSADMINACCOUNTS='BUILTIN\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS ; \ 22 | Remove-Item -Recurse -Force sqlexpress.exe, setup 23 | 24 | RUN stop-service MSSQL`$SQLEXPRESS ; \ 25 | set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; \ 26 | set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; \ 27 | set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver\' -name LoginMode -value 2 ; 28 | 29 | CMD .\start -sa_password $env:sa_password -ACCEPT_EULA $env:ACCEPT_EULA -attach_dbs \"$env:attach_dbs\" -Verbose 30 | -------------------------------------------------------------------------------- /windows/mssql-server-windows-express/readme.md: -------------------------------------------------------------------------------- 1 | ## Note: The SQL Server Express on Windows image is not supported for production use. If you have a need to use SQL Server on Windows containers in production, please sign up for the Early Adoption Preview at https://aka.ms/sqleap 2 | 3 | # mssql-server-windows-express 4 | This Dockerfile helps developers to get started using SQL Server Express in Windows Containers. The file downloads and installs SQL Server Express with the default setup parameters. 5 | 6 | ### Contents 7 | 8 | [About this sample](#about-this-sample)
9 | [Before you begin](#before-you-begin)
10 | [Run this sample](#run-this-sample)
11 | [Sample details](#sample-details)
12 | [Disclaimers](#disclaimers)
13 | [Related links](#related-links)
14 | 15 | 16 | 17 | ## About this sample 18 | 19 | 1. **Applies to:** SQL Server 2016 SP1 Express, Windows Server 2016 20 | 5. **Authors:** Perry Skountrianos [perrysk-msft] 21 | 22 | 23 | 24 | ## Before you begin 25 | 26 | To run this sample, you need the following prerequisites. 27 | 28 | **Software prerequisites:** 29 | 30 | You can run the container with the following command. 31 | (Note the you'll need Windows Server 2016 or Windows 10) 32 | 33 | ```` 34 | docker run -d -p 1433:1433 -v C:/temp/:C:/temp/ -e sa_password= -e ACCEPT_EULA=Y -e attach_dbs="" microsoft/mssql-server-windows-express 35 | ```` 36 | 37 | - **-p HostPort:containerPort** is for port-mapping a container network port to a host port. 38 | - **-v HostPath:containerPath** is for mounting a folder from the host inside the container. 39 | 40 | This can be used for saving database outside of the container. 41 | 42 | - **-it** can be used to show the verbose output of the SQL startup script. 43 | 44 | Use this to debug the container in case of issues. 45 | 46 | 47 | 48 | ## Run this sample 49 | 50 | The image provides two environment variables to optionally set:
51 | - **accept_eula**: Confirms acceptance of the end user licensing agreement found [here](http://go.microsoft.com/fwlink/?LinkId=746388) 52 | - **sa_password**: Sets the sa password and enables the sa login 53 | - **attach_dbs**: The configuration for attaching custom DBs (.mdf, .ldf files). 54 | 55 | This should be a JSON string, in the following format (note the use of SINGLE quotes!) 56 | ``` 57 | [ 58 | { 59 | 'dbName': 'MaxDb', 60 | 'dbFiles': ['C:\\temp\\maxtest.mdf', 61 | 'C:\\temp\\maxtest_log.ldf'] 62 | }, 63 | { 64 | 'dbName': 'PerryDb', 65 | 'dbFiles': ['C:\\temp\\perrytest.mdf', 66 | 'C:\\temp\\perrytest_log.ldf'] 67 | } 68 | ] 69 | ``` 70 | 71 | This is an array of databases, which can have zero to N databases. 72 | 73 | Each consisting of: 74 | - **dbName**: The name of the database 75 | - **dbFiles**: An array of one or many absolute paths to the .MDF and .LDF files. 76 | 77 | **Note:** 78 | The path has double backslashes for escaping! 79 | The path refers to files **within the container**. So make sure to include them in the image or mount them via **-v**! 80 | 81 | 82 | This example shows all parameters in action: 83 | ``` 84 | docker run -d -p 1433:1433 -v C:/temp/:C:/temp/ -e sa_password= -e ACCEPT_EULA=Y -e attach_dbs="[{'dbName':'SampleDB','dbFiles':['C:\\temp\\sampledb.mdf','C:\\temp\\sampledb_log. 85 | ldf']}]" microsoft/mssql-server-windows-express 86 | ``` 87 | 88 | 89 | 90 | ## Sample details 91 | 92 | The Dockerfile downloads and installs SQL Server 2016 Express with the following default setup parameters that could be changed (if needed) after the image is installed. 93 | - Collation: SQL_Latin1_General_CP1_CI_AS 94 | - SQL Instance Name: SQLEXPRESS 95 | - Root Directory: C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL 96 | - Language: English (United Stated) 97 | 98 | 99 | 100 | ## Disclaimers 101 | The code included in this sample is not intended to be a set of best practices on how to build scalable enterprise grade applications. This is beyond the scope of this quick start sample. 102 | 103 | 104 | 105 | ## Related Links 106 | 107 | 108 | For more information, see these articles: 109 | - [Windows Containers](https://msdn.microsoft.com/en-us/virtualization/windowscontainers/about/about_overview) 110 | - [Windows-based containers: Modern app development with enterprise-grade control](https://www.youtube.com/watch?v=Ryx3o0rD5lY&feature=youtu.be) 111 | - [Windows Containers: What, Why and How](https://channel9.msdn.com/Events/Build/2015/2-704) 112 | - [SQL Server in Windows Containers](https://blogs.msdn.microsoft.com/sqlserverstorageengine/2016/03/21/sql-server-in-windows-containers/#comments) 113 | -------------------------------------------------------------------------------- /windows/mssql-server-windows-express/start.ps1: -------------------------------------------------------------------------------- 1 | # The script sets the sa password and start the SQL Service 2 | # Also it attaches additional database from the disk 3 | # The format for attach_dbs 4 | 5 | param( 6 | [Parameter(Mandatory=$false)] 7 | [string]$sa_password, 8 | 9 | [Parameter(Mandatory=$false)] 10 | [string]$ACCEPT_EULA, 11 | 12 | [Parameter(Mandatory=$false)] 13 | [string]$attach_dbs 14 | ) 15 | 16 | 17 | if($ACCEPT_EULA -ne "Y" -And $ACCEPT_EULA -ne "y") 18 | { 19 | Write-Verbose "ERROR: You must accept the End User License Agreement before this container can start." 20 | Write-Verbose "Set the environment variable ACCEPT_EULA to 'Y' if you accept the agreement." 21 | 22 | exit 1 23 | } 24 | 25 | # start the service 26 | Write-Verbose "Starting SQL Server" 27 | start-service MSSQL`$SQLEXPRESS 28 | 29 | if($sa_password -eq "_") { 30 | $secretPath = $env:sa_password_path 31 | if (Test-Path $secretPath) { 32 | $sa_password = Get-Content -Raw $secretPath 33 | } 34 | else { 35 | Write-Verbose "WARN: Using default SA password, secret file not found at: $secretPath" 36 | } 37 | } 38 | 39 | if($sa_password -ne "_") 40 | { 41 | Write-Verbose "Changing SA login credentials" 42 | $sqlcmd = "ALTER LOGIN sa with password=" +"'" + $sa_password + "'" + ";ALTER LOGIN sa ENABLE;" 43 | & sqlcmd -Q $sqlcmd 44 | } 45 | 46 | $attach_dbs_cleaned = $attach_dbs.TrimStart('\\').TrimEnd('\\') 47 | 48 | $dbs = $attach_dbs_cleaned | ConvertFrom-Json 49 | 50 | if ($null -ne $dbs -And $dbs.Length -gt 0) 51 | { 52 | Write-Verbose "Attaching $($dbs.Length) database(s)" 53 | 54 | Foreach($db in $dbs) 55 | { 56 | $files = @(); 57 | Foreach($file in $db.dbFiles) 58 | { 59 | $files += "(FILENAME = N'$($file)')"; 60 | } 61 | 62 | $files = $files -join "," 63 | $sqlcmd = "IF EXISTS (SELECT 1 FROM SYS.DATABASES WHERE NAME = '" + $($db.dbName) + "') BEGIN EXEC sp_detach_db [$($db.dbName)] END;CREATE DATABASE [$($db.dbName)] ON $($files) FOR ATTACH;" 64 | 65 | Write-Verbose "Invoke-Sqlcmd -Query $($sqlcmd)" 66 | & sqlcmd -Q $sqlcmd 67 | } 68 | } 69 | 70 | Write-Verbose "Started SQL Server." 71 | 72 | $lastCheck = (Get-Date).AddSeconds(-2) 73 | while ($true) 74 | { 75 | Get-EventLog -LogName Application -Source "MSSQL*" -After $lastCheck | Select-Object TimeGenerated, EntryType, Message 76 | $lastCheck = Get-Date 77 | Start-Sleep -Seconds 2 78 | } 79 | -------------------------------------------------------------------------------- /windows/mssql-server-windows/dockerfile: -------------------------------------------------------------------------------- 1 | FROM microsoft/windowsservercore 2 | 3 | LABEL maintainer "Perry Skountrianos" 4 | 5 | # SQL Server 2016 vNext: 6 | ENV exe "https://go.microsoft.com/fwlink/?linkid=835677" 7 | ENV box "https://go.microsoft.com/fwlink/?linkid=835679" 8 | 9 | ENV sa_password="_" \ 10 | attach_dbs="[]" \ 11 | ACCEPT_EULA="_" \ 12 | sa_password_path="C:\ProgramData\Docker\secrets\sa-password" 13 | 14 | SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] 15 | 16 | # make install files accessible 17 | COPY start.ps1 / 18 | WORKDIR / 19 | 20 | RUN Invoke-WebRequest -Uri $env:box -OutFile SQL.box ; \ 21 | Invoke-WebRequest -Uri $env:exe -OutFile SQL.exe ; \ 22 | Start-Process -Wait -FilePath .\SQL.exe -ArgumentList /qs, /x:setup ; \ 23 | .\setup\setup.exe /q /ACTION=Install /INSTANCENAME=MSSQLSERVER /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT='NT AUTHORITY\System' /SQLSYSADMINACCOUNTS='BUILTIN\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS ; \ 24 | Remove-Item -Recurse -Force SQL.exe, SQL.box, setup 25 | 26 | RUN stop-service MSSQLSERVER ; \ 27 | set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.MSSQLSERVER\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; \ 28 | set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.MSSQLSERVER\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; \ 29 | set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.MSSQLSERVER\mssqlserver\' -name LoginMode -value 2 ; 30 | 31 | HEALTHCHECK CMD [ "sqlcmd", "-Q", "select 1" ] 32 | 33 | CMD .\start -sa_password $env:sa_password -ACCEPT_EULA $env:ACCEPT_EULA -attach_dbs \"$env:attach_dbs\" -Verbose 34 | -------------------------------------------------------------------------------- /windows/mssql-server-windows/readme.md: -------------------------------------------------------------------------------- 1 | # mssql-server-windows 2 | This Dockerfile helps developers to get started using SQL Server vNext in Windows Containers. The file downloads and installs SQL Server vNext with the default setup parameters. 3 | 4 | ### Contents 5 | 6 | [About this sample](#about-this-sample)
7 | [Before you begin](#before-you-begin)
8 | [Run this sample](#run-this-sample)
9 | [Sample details](#sample-details)
10 | [Disclaimers](#disclaimers)
11 | [Related links](#related-links)
12 | 13 | 14 | 15 | ## About this sample 16 | 17 | 1. **Applies to:** SQL Server vNext, Windows Server 2016, Windows 10 18 | 5. **Authors:** Perry Skountrianos [perrysk-msft] 19 | 20 | 21 | 22 | ## Before you begin 23 | 24 | To run this sample, you need the following prerequisites. 25 | 26 | **Software prerequisites:** 27 | 28 | You can run the container with the following command. 29 | (Note the you'll need Windows Server 2016 or Windows 10) 30 | 31 | ```` 32 | docker run -d -p 1433:1433 -v C:/temp/:C:/temp/ -e sa_password= -e ACCEPT_EULA=Y -e attach_dbs="" microsoft/mssql-server-windows 33 | ```` 34 | 35 | - **-p HostPort:containerPort** is for port-mapping a container network port to a host port. 36 | - **-v HostPath:containerPath** is for mounting a folder from the host inside the container. 37 | 38 | This can be used for saving database outside of the container. 39 | 40 | - **-it** can be used to show the verbose output of the SQL startup script. 41 | 42 | Use this to debug the container in case of issues. 43 | 44 | 45 | 46 | ## Run this sample 47 | 48 | The image provides two environment variables to optionally set:
49 | - **accept_eula**: Confirms acceptance of the end user licensing agreement found [here](http://go.microsoft.com/fwlink/?LinkId=746388) 50 | - **sa_password**: Sets the sa password and enables the sa login 51 | - **attach_dbs**: The configuration for attaching custom DBs (.mdf, .ldf files). 52 | 53 | This should be a JSON string, in the following format (note the use of SINGLE quotes!) 54 | ``` 55 | [ 56 | { 57 | 'dbName': 'MaxDb', 58 | 'dbFiles': ['C:\\temp\\maxtest.mdf', 59 | 'C:\\temp\\maxtest_log.ldf'] 60 | }, 61 | { 62 | 'dbName': 'PerryDb', 63 | 'dbFiles': ['C:\\temp\\perrytest.mdf', 64 | 'C:\\temp\\perrytest_log.ldf'] 65 | } 66 | ] 67 | ``` 68 | 69 | This is an array of databases, which can have zero to N databases. 70 | 71 | Each consisting of: 72 | - **dbName**: The name of the database 73 | - **dbFiles**: An array of one or many absolute paths to the .MDF and .LDF files. 74 | 75 | **Note:** 76 | The path has double backslashes for escaping! 77 | The path refers to files **within the container**. So make sure to include them in the image or mount them via **-v**! 78 | 79 | 80 | This example shows all parameters in action: 81 | ``` 82 | docker run -d -p 1433:1433 -v C:/temp/:C:/temp/ -e sa_password= -e ACCEPT_EULA=Y -e attach_dbs="[{'dbName':'SampleDB','dbFiles':['C:\\temp\\sampledb.mdf','C:\\temp\\sampledb_log. 83 | ldf']}]" microsoft/mssql-server-windows 84 | ``` 85 | 86 | 87 | 88 | ## Sample details 89 | 90 | The Dockerfile downloads and installs SQL Server 2016 Express with the following default setup parameters that could be changed (if needed) after the image is installed. 91 | - Collation: SQL_Latin1_General_CP1_CI_AS 92 | - SQL Instance Name: SQLEXPRESS 93 | - Root Directory: C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL 94 | - Language: English (United Stated) 95 | 96 | 97 | 98 | ## Disclaimers 99 | The code included in this sample is not intended to be a set of best practices on how to build scalable enterprise grade applications. This is beyond the scope of this quick start sample. 100 | 101 | 102 | 103 | ## Related Links 104 | 105 | 106 | For more information, see these articles: 107 | - [Windows Containers](https://msdn.microsoft.com/en-us/virtualization/windowscontainers/about/about_overview) 108 | - [Windows-based containers: Modern app development with enterprise-grade control](https://www.youtube.com/watch?v=Ryx3o0rD5lY&feature=youtu.be) 109 | - [Windows Containers: What, Why and How](https://channel9.msdn.com/Events/Build/2015/2-704) 110 | - [SQL Server in Windows Containers](https://blogs.msdn.microsoft.com/sqlserverstorageengine/2016/03/21/sql-server-in-windows-containers/#comments) 111 | -------------------------------------------------------------------------------- /windows/mssql-server-windows/start.ps1: -------------------------------------------------------------------------------- 1 | # The script sets the sa password and start the SQL Service 2 | # Also it attaches additional database from the disk 3 | # The format for attach_dbs 4 | 5 | param( 6 | [Parameter(Mandatory=$false)] 7 | [string]$sa_password, 8 | 9 | [Parameter(Mandatory=$false)] 10 | [string]$ACCEPT_EULA, 11 | 12 | [Parameter(Mandatory=$false)] 13 | [string]$attach_dbs 14 | ) 15 | 16 | 17 | if($ACCEPT_EULA -ne "Y" -And $ACCEPT_EULA -ne "y") 18 | { 19 | Write-Verbose "ERROR: You must accept the End User License Agreement before this container can start." 20 | Write-Verbose "Set the environment variable ACCEPT_EULA to 'Y' if you accept the agreement." 21 | 22 | exit 1 23 | } 24 | 25 | # start the service 26 | Write-Verbose "Starting SQL Server" 27 | start-service MSSQLSERVER 28 | 29 | if($sa_password -eq "_") { 30 | if (Test-Path $env:sa_password_path) { 31 | $sa_password = Get-Content -Raw $secretPath 32 | } 33 | else { 34 | Write-Verbose "WARN: Using default SA password, secret file not found at: $secretPath" 35 | } 36 | } 37 | 38 | if($sa_password -ne "_") 39 | { 40 | Write-Verbose "Changing SA login credentials" 41 | $sqlcmd = "ALTER LOGIN sa with password=" +"'" + $sa_password + "'" + ";ALTER LOGIN sa ENABLE;" 42 | & sqlcmd -Q $sqlcmd 43 | } 44 | 45 | $attach_dbs_cleaned = $attach_dbs.TrimStart('\\').TrimEnd('\\') 46 | 47 | $dbs = $attach_dbs_cleaned | ConvertFrom-Json 48 | 49 | if ($null -ne $dbs -And $dbs.Length -gt 0) 50 | { 51 | Write-Verbose "Attaching $($dbs.Length) database(s)" 52 | 53 | Foreach($db in $dbs) 54 | { 55 | if($db.saskey.length -gt 0) 56 | { 57 | $saskey = $true 58 | } 59 | else 60 | { 61 | $saskey = $false 62 | } 63 | 64 | $files = @(); 65 | Foreach($file in $db.dbFiles) 66 | { 67 | $files += "(FILENAME = N'$($file)')"; 68 | 69 | # check for a saskey and create one credential per blob Container 70 | if($saskey) 71 | { 72 | $blob_container = (Split-Path $file).Replace('\','/'); 73 | $sql_credential = "IF NOT EXISTS (SELECT 1 FROM SYS.CREDENTIALS WHERE NAME = '" + $blob_container + "') BEGIN CREATE CREDENTIAL [" + $blob_container + "] WITH IDENTITY='SHARED ACCESS SIGNATURE', SECRET= '" + $db.saskey + "' END;" 74 | 75 | Write-Verbose "Invoke-Sqlcmd -Query $($sql_credential)" 76 | & sqlcmd -Q $sql_credential 77 | } 78 | } 79 | 80 | $files = $files -join "," 81 | $sqlcmd = "sp_detach_db ""$($db.dbName)"";CREATE DATABASE ""$($db.dbName)"" ON $($files) FOR ATTACH ;" 82 | 83 | Write-Verbose "Invoke-Sqlcmd -Query $($sqlcmd)" 84 | & sqlcmd -Q $sqlcmd 85 | } 86 | } 87 | 88 | Write-Verbose "Started SQL Server." 89 | 90 | $lastCheck = (Get-Date).AddSeconds(-2) 91 | while ($true) 92 | { 93 | Get-EventLog -LogName Application -Source "MSSQL*" -After $lastCheck | Select-Object TimeGenerated, EntryType, Message 94 | $lastCheck = Get-Date 95 | Start-Sleep -Seconds 2 96 | } 97 | --------------------------------------------------------------------------------