mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
Updating links for Windows Containers
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
# mssql server 2014 express image listening on static port 1433
|
||||
#
|
||||
# Note: This dockerfile is based on Buc Rogers' work here:
|
||||
# https://github.com/brogersyh/Dockerfiles-for-windows/tree/master/sqlexpress
|
||||
#
|
||||
# .NET 3.5 required for SQL Server
|
||||
FROM microsoft/dotnet-framework:3.5
|
||||
|
||||
# maintainer for image metadata
|
||||
MAINTAINER Perry Skountrianos
|
||||
|
||||
# set environment variables
|
||||
ENV sql_express_download_url "https://download.microsoft.com/download/1/5/6/156992E6-F7C7-4E55-833D-249BD2348138/ENU/x64/SQLEXPR_x64_ENU.exe"
|
||||
ENV sa_password _
|
||||
ENV attach_dbs "[]"
|
||||
|
||||
# make install files accessible
|
||||
COPY . /
|
||||
WORKDIR /
|
||||
|
||||
# download and install Microsoft SQL 2014 Express Edition in one step
|
||||
RUN powershell -Command (New-Object System.Net.WebClient).DownloadFile('%sql_express_download_url%', 'sqlexpress.exe') && /sqlexpress.exe /qs /x:setup && /setup/setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT="NT AUTHORITY\System" /SQLSYSADMINACCOUNTS="BUILTIN\ADMINISTRATORS" /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS && del /F /Q sqlexpress.exe && rd /q /s setup
|
||||
|
||||
RUN powershell -Command \
|
||||
set-strictmode -version latest ; \
|
||||
stop-service MSSQL`$SQLEXPRESS ; \
|
||||
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql12.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; \
|
||||
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql12.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; \
|
||||
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql12.SQLEXPRESS\mssqlserver\' -name LoginMode -value 2 ;
|
||||
|
||||
CMD powershell ./start -sa_password %sa_password% -attach_dbs \"%attach_dbs%\" -Verbose
|
||||
@@ -1,111 +0,0 @@
|
||||
# mssql-server-2014-express-windows
|
||||
This Dockerfile helps developers to get started using SQL Server 2014 Express in Windows Server Core Containers. The file downloads and installs SQL Server 2014 Express with the default setup parameters.
|
||||
|
||||
Note: This dockerfile is based on Buc Rogers' work that can be found [here] (https://github.com/brogersyh/Dockerfiles-for-windows/tree/master/sqlexpress)
|
||||
|
||||
### Contents
|
||||
|
||||
[About this sample](#about-this-sample)<br/>
|
||||
[Before you begin](#before-you-begin)<br/>
|
||||
[Run this sample](#run-this-sample)<br/>
|
||||
[Sample details](#sample-details)<br/>
|
||||
[Disclaimers](#disclaimers)<br/>
|
||||
[Related links](#related-links)<br/>
|
||||
|
||||
<a name=about-this-sample></a>
|
||||
|
||||
## About this sample
|
||||
|
||||
1. **Applies to:** SQL Server 2014 Express, Windows Server Technical Preview 4 or later
|
||||
5. **Authors:** Perry Skountrianos [perrysk-msft], Max Knor [knom]
|
||||
|
||||
<a name=before-you-begin></a>
|
||||
|
||||
## Before you begin
|
||||
|
||||
To run this sample, you need the following prerequisites.
|
||||
|
||||
**Software prerequisites:**
|
||||
|
||||
You can run the container with the following command.
|
||||
(Note the you'll need Windows Server Core TP5 v10.0.14300.1030.)
|
||||
|
||||
````
|
||||
docker run -p 1433:1433 -v C:/temp/:C:/temp/ --env sa_password=<YOUR SA PASSWORD> --env attach_dbs="<DB-JSON-CONFIG>" microsoft/mssql-server-2014-express-windows
|
||||
````
|
||||
|
||||
- **-p HostPort:containerPort** is for port-mapping a container network port to a host port.
|
||||
- **-v HostPath:containerPath** is for mounting a folder from the host inside the container.
|
||||
|
||||
This can be used for saving database outside of the container.
|
||||
|
||||
- **-it** can be used to show the verbose output of the SQL startup script.
|
||||
|
||||
Use this to debug the container in case of issues.
|
||||
|
||||
<a name=run-this-sample></a>
|
||||
|
||||
## Run this sample
|
||||
|
||||
The image provides two environment variables to optionally set: </br>
|
||||
- **sa_password**: Sets the sa password and enables the sa login
|
||||
- **attach_dbs**: The configuration for attaching custom DBs (.mdf, .ldf files).
|
||||
|
||||
This should be a JSON string, in the following format (note the use of SINGLE quotes!)
|
||||
```
|
||||
[
|
||||
{
|
||||
'dbName': 'MaxDb',
|
||||
'dbFiles': ['C:\\temp\\maxtest.mdf',
|
||||
'C:\\temp\\maxtest_log.ldf']
|
||||
},
|
||||
{
|
||||
'dbName': 'PerryDb',
|
||||
'dbFiles': ['C:\\temp\\perrytest.mdf',
|
||||
'C:\\temp\\perrytest_log.ldf']
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
This is an array of databases, which can have zero to N databases.
|
||||
|
||||
Each consisting of:
|
||||
- **dbName**: The name of the database
|
||||
- **dbFiles**: An array of one or many absolute paths to the .MDF and .LDF files.
|
||||
|
||||
**Note:**
|
||||
The path has double backslashes for escaping!
|
||||
The path refers to files **within the container**. So make sure to include them in the image or mount them via **-v**!
|
||||
|
||||
|
||||
This example shows all parameters in action:
|
||||
```
|
||||
docker run -p 1433:1433 -v C:/temp/:C:/temp/ --env attach_dbs="[{'dbName':'MaxTest','dbFiles':['C:\\temp\\maxtest.mdf','C:\\temp\\maxtest_log.
|
||||
ldf']}]" microsoft/mssql-server-2014-express-windows
|
||||
```
|
||||
|
||||
<a name=sample-details></a>
|
||||
|
||||
## Sample details
|
||||
|
||||
The Dockerfile downloads and installs SQL Server 2014 Express with the following default setup parameters that could be changed (if needed) after the image is installed.
|
||||
- Collation: SQL_Latin1_General_CP1_CI_AS
|
||||
- SQL Instance Name: SQLEXPRESS
|
||||
- Root Directory: C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL
|
||||
- Language: English (United Stated)
|
||||
|
||||
<a name=disclaimers></a>
|
||||
|
||||
## Disclaimers
|
||||
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.
|
||||
|
||||
<a name=related-links></a>
|
||||
|
||||
## Related Links
|
||||
<!-- Links to more articles. Remember to delete "en-us" from the link path. -->
|
||||
|
||||
For more information, see these articles:
|
||||
- [Windows Containers] (https://msdn.microsoft.com/en-us/virtualization/windowscontainers/about/about_overview)
|
||||
- [Windows-based containers: Modern app development with enterprise-grade control] (https://www.youtube.com/watch?v=Ryx3o0rD5lY&feature=youtu.be)
|
||||
- [Windows Containers: What, Why and How] (https://channel9.msdn.com/Events/Build/2015/2-704)
|
||||
- [SQL Server in Windows Containers] (https://blogs.msdn.microsoft.com/sqlserverstorageengine/2016/03/21/sql-server-in-windows-containers/#comments)
|
||||
@@ -1,46 +0,0 @@
|
||||
# The script sets the sa password and start the SQL Service
|
||||
# Also it attaches additional database from the disk
|
||||
# The format for attach_dbs
|
||||
|
||||
param(
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$sa_password,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$attach_dbs
|
||||
)
|
||||
|
||||
# start the service
|
||||
Write-Verbose "Starting SQL Server..."
|
||||
start-service MSSQL`$SQLEXPRESS
|
||||
|
||||
if($sa_password -ne "_"){
|
||||
Write-Verbose "Changing SA login credentials"
|
||||
$sqlcmd = "ALTER LOGIN sa with password=" +"'" + $sa_password + "'" + ";ALTER LOGIN sa ENABLE;"
|
||||
Invoke-Sqlcmd -Query $sqlcmd -ServerInstance ".\SQLEXPRESS"
|
||||
}
|
||||
|
||||
$attach_dbs_cleaned = $attach_dbs.TrimStart('\\').TrimEnd('\\')
|
||||
|
||||
$dbs = $attach_dbs_cleaned | ConvertFrom-Json
|
||||
|
||||
if ($null -ne $dbs -And $dbs.Length -gt 0){
|
||||
Write-Verbose "Attaching $($dbs.Length) database(s)"
|
||||
Foreach($db in $dbs)
|
||||
{
|
||||
$files = @();
|
||||
Foreach($file in $db.dbFiles)
|
||||
{
|
||||
$files += "(FILENAME = N'$($file)')";
|
||||
}
|
||||
|
||||
$files = $files -join ","
|
||||
$sqlcmd = "sp_detach_db $($db.dbName);CREATE DATABASE $($db.dbName) ON $($files) FOR ATTACH ;"
|
||||
|
||||
Write-Verbose "Invoke-Sqlcmd -Query $($sqlcmd) -ServerInstance '.\SQLEXPRESS'"
|
||||
Invoke-Sqlcmd -Query $sqlcmd -ServerInstance ".\SQLEXPRESS"
|
||||
}
|
||||
}
|
||||
|
||||
Write-Verbose "Started SQL Server."
|
||||
while ($true) { Start-Sleep -Seconds 3600 }
|
||||
@@ -1,28 +0,0 @@
|
||||
# mssql server 2016 SP1 express image
|
||||
FROM microsoft/windowsservercore
|
||||
|
||||
# maintainer for image metadata
|
||||
MAINTAINER Perry Skountrianos
|
||||
|
||||
# set environment variables
|
||||
ENV sql_express_download_url "https://go.microsoft.com/fwlink/?linkid=829176"
|
||||
|
||||
ENV sa_password _
|
||||
ENV attach_dbs "[]"
|
||||
ENV ACCEPT_EULA _
|
||||
|
||||
# make install files accessible
|
||||
COPY . /
|
||||
WORKDIR /
|
||||
|
||||
# download and install Microsoft SQL 2016 Express Edition in one step
|
||||
RUN powershell -Command (New-Object System.Net.WebClient).DownloadFile('%sql_express_download_url%', 'sqlexpress.exe') && /sqlexpress.exe /qs /x:setup && /setup/setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT="NT AUTHORITY\System" /SQLSYSADMINACCOUNTS="BUILTIN\ADMINISTRATORS" /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS && del /F /Q sqlexpress.exe && rd /q /s setup
|
||||
|
||||
RUN powershell -Command \
|
||||
set-strictmode -version latest ; \
|
||||
stop-service MSSQL`$SQLEXPRESS ; \
|
||||
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql13.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; \
|
||||
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql13.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; \
|
||||
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql13.SQLEXPRESS\mssqlserver\' -name LoginMode -value 2 ;
|
||||
|
||||
CMD powershell ./start -sa_password %sa_password% -ACCEPT_EULA %ACCEPT_EULA% -attach_dbs \"%attach_dbs%\" -Verbose
|
||||
@@ -1,110 +0,0 @@
|
||||
# mssql-server-2016-sp1-express-windows
|
||||
This Dockerfile helps developers to get started using SQL Server 2016 SP1 Express in Windows Containers. The file downloads and installs SQL Server 2016 SP1 Express with the default setup parameters.
|
||||
|
||||
### Contents
|
||||
|
||||
[About this sample](#about-this-sample)<br/>
|
||||
[Before you begin](#before-you-begin)<br/>
|
||||
[Run this sample](#run-this-sample)<br/>
|
||||
[Sample details](#sample-details)<br/>
|
||||
[Disclaimers](#disclaimers)<br/>
|
||||
[Related links](#related-links)<br/>
|
||||
|
||||
<a name=about-this-sample></a>
|
||||
|
||||
## About this sample
|
||||
|
||||
1. **Applies to:** SQL Server 2016 SP1 Express, Windows Server 2016
|
||||
5. **Authors:** Perry Skountrianos [perrysk-msft]
|
||||
|
||||
<a name=before-you-begin></a>
|
||||
|
||||
## Before you begin
|
||||
|
||||
To run this sample, you need the following prerequisites.
|
||||
|
||||
**Software prerequisites:**
|
||||
|
||||
You can run the container with the following command.
|
||||
(Note the you'll need Windows Server 2016 or Windows 10)
|
||||
|
||||
````
|
||||
docker run -d -p 1433:1433 -v C:/temp/:C:/temp/ -e sa_password=<YOUR SA PASSWORD> -e ACCEPT_EULA=Y -e attach_dbs="<DB-JSON-CONFIG>" microsoft/mssql-server-windows-express
|
||||
````
|
||||
|
||||
- **-p HostPort:containerPort** is for port-mapping a container network port to a host port.
|
||||
- **-v HostPath:containerPath** is for mounting a folder from the host inside the container.
|
||||
|
||||
This can be used for saving database outside of the container.
|
||||
|
||||
- **-it** can be used to show the verbose output of the SQL startup script.
|
||||
|
||||
Use this to debug the container in case of issues.
|
||||
|
||||
<a name=run-this-sample></a>
|
||||
|
||||
## Run this sample
|
||||
|
||||
The image provides two environment variables to optionally set: </br>
|
||||
- **accepot_eula**: Confirms acceptance of the end user licensing agreement found [here](http://go.microsoft.com/fwlink/?LinkId=746388)
|
||||
- **sa_password**: Sets the sa password and enables the sa login
|
||||
- **attach_dbs**: The configuration for attaching custom DBs (.mdf, .ldf files).
|
||||
|
||||
This should be a JSON string, in the following format (note the use of SINGLE quotes!)
|
||||
```
|
||||
[
|
||||
{
|
||||
'dbName': 'MaxDb',
|
||||
'dbFiles': ['C:\\temp\\maxtest.mdf',
|
||||
'C:\\temp\\maxtest_log.ldf']
|
||||
},
|
||||
{
|
||||
'dbName': 'PerryDb',
|
||||
'dbFiles': ['C:\\temp\\perrytest.mdf',
|
||||
'C:\\temp\\perrytest_log.ldf']
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
This is an array of databases, which can have zero to N databases.
|
||||
|
||||
Each consisting of:
|
||||
- **dbName**: The name of the database
|
||||
- **dbFiles**: An array of one or many absolute paths to the .MDF and .LDF files.
|
||||
|
||||
**Note:**
|
||||
The path has double backslashes for escaping!
|
||||
The path refers to files **within the container**. So make sure to include them in the image or mount them via **-v**!
|
||||
|
||||
|
||||
This example shows all parameters in action:
|
||||
```
|
||||
docker run -d -p 1433:1433 -v C:/temp/:C:/temp/ -e sa_password=<YOUR SA PASSWORD> -e ACCEPT_EULA=Y -e attach_dbs="[{'dbName':'SampleDB','dbFiles':['C:\\temp\\sampledb.mdf','C:\\temp\\sampledb_log.
|
||||
ldf']}]" microsoft/mssql-server-windows-express
|
||||
```
|
||||
|
||||
<a name=sample-details></a>
|
||||
|
||||
## Sample details
|
||||
|
||||
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.
|
||||
- Collation: SQL_Latin1_General_CP1_CI_AS
|
||||
- SQL Instance Name: SQLEXPRESS
|
||||
- Root Directory: C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL
|
||||
- Language: English (United Stated)
|
||||
|
||||
<a name=disclaimers></a>
|
||||
|
||||
## Disclaimers
|
||||
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.
|
||||
|
||||
<a name=related-links></a>
|
||||
|
||||
## Related Links
|
||||
<!-- Links to more articles. Remember to delete "en-us" from the link path. -->
|
||||
|
||||
For more information, see these articles:
|
||||
- [Windows Containers] (https://msdn.microsoft.com/en-us/virtualization/windowscontainers/about/about_overview)
|
||||
- [Windows-based containers: Modern app development with enterprise-grade control] (https://www.youtube.com/watch?v=Ryx3o0rD5lY&feature=youtu.be)
|
||||
- [Windows Containers: What, Why and How] (https://channel9.msdn.com/Events/Build/2015/2-704)
|
||||
- [SQL Server in Windows Containers] (https://blogs.msdn.microsoft.com/sqlserverstorageengine/2016/03/21/sql-server-in-windows-containers/#comments)
|
||||
@@ -1,57 +0,0 @@
|
||||
# The script sets the sa password and start the SQL Service
|
||||
# Also it attaches additional database from the disk
|
||||
# The format for attach_dbs
|
||||
|
||||
param(
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$sa_password,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$ACCEPT_EULA,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$attach_dbs
|
||||
)
|
||||
|
||||
|
||||
if($ACCEPT_EULA -ne "Y" -And $ACCEPT_EULA -ne "y"){
|
||||
Write-Verbose "ERROR: You must accept the End User License Agreement before this container can start."
|
||||
Write-Verbose "Set the environment variable ACCEPT_EULA to 'Y' if you accept the agreement."
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
# start the service
|
||||
Write-Verbose "Starting SQL Server"
|
||||
start-service MSSQL`$SQLEXPRESS
|
||||
|
||||
if($sa_password -ne "_"){
|
||||
Write-Verbose "Changing SA login credentials"
|
||||
$sqlcmd = "ALTER LOGIN sa with password=" +"'" + $sa_password + "'" + ";ALTER LOGIN sa ENABLE;"
|
||||
Invoke-Sqlcmd -Query $sqlcmd -ServerInstance ".\SQLEXPRESS"
|
||||
}
|
||||
|
||||
$attach_dbs_cleaned = $attach_dbs.TrimStart('\\').TrimEnd('\\')
|
||||
|
||||
$dbs = $attach_dbs_cleaned | ConvertFrom-Json
|
||||
|
||||
if ($null -ne $dbs -And $dbs.Length -gt 0){
|
||||
Write-Verbose "Attaching $($dbs.Length) database(s)"
|
||||
Foreach($db in $dbs)
|
||||
{
|
||||
$files = @();
|
||||
Foreach($file in $db.dbFiles)
|
||||
{
|
||||
$files += "(FILENAME = N'$($file)')";
|
||||
}
|
||||
|
||||
$files = $files -join ","
|
||||
$sqlcmd = "sp_detach_db ""$($db.dbName)"";CREATE DATABASE ""$($db.dbName)"" ON $($files) FOR ATTACH ;"
|
||||
|
||||
Write-Verbose "Invoke-Sqlcmd -Query $($sqlcmd) -ServerInstance '.\SQLEXPRESS'"
|
||||
Invoke-Sqlcmd -Query $sqlcmd -ServerInstance ".\SQLEXPRESS"
|
||||
}
|
||||
}
|
||||
|
||||
Write-Verbose "Started SQL Server."
|
||||
while ($true) { Start-Sleep -Seconds 3600 }
|
||||
@@ -1,28 +0,0 @@
|
||||
# mssql server 2016 express image
|
||||
#
|
||||
FROM microsoft/windowsservercore
|
||||
|
||||
# maintainer for image metadata
|
||||
MAINTAINER Perry Skountrianos
|
||||
|
||||
# set environment variables
|
||||
ENV sql_express_download_url "https://go.microsoft.com/fwlink/?linkid=829176"
|
||||
|
||||
ENV sa_password _
|
||||
ENV attach_dbs "[]"
|
||||
|
||||
# make install files accessible
|
||||
COPY . /
|
||||
WORKDIR /
|
||||
|
||||
# download and install Microsoft SQL 2016 Express Edition in one step
|
||||
RUN powershell -Command (New-Object System.Net.WebClient).DownloadFile('%sql_express_download_url%', 'sqlexpress.exe') && /sqlexpress.exe /qs /x:setup && /setup/setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT="NT AUTHORITY\System" /SQLSYSADMINACCOUNTS="BUILTIN\ADMINISTRATORS" /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS && del /F /Q sqlexpress.exe && rd /q /s setup
|
||||
|
||||
RUN powershell -Command \
|
||||
set-strictmode -version latest ; \
|
||||
stop-service MSSQL`$SQLEXPRESS ; \
|
||||
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql13.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; \
|
||||
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql13.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; \
|
||||
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql13.SQLEXPRESS\mssqlserver\' -name LoginMode -value 2 ;
|
||||
|
||||
CMD powershell ./start -sa_password %sa_password% -attach_dbs \"%attach_dbs%\" -Verbose
|
||||
@@ -1,109 +0,0 @@
|
||||
# mssql-server-2016-express-windows
|
||||
This Dockerfile helps developers to get started using SQL Server 2016 Express in Windows Server Core Containers. The file downloads and installs SQL Server 2016 Express with the default setup parameters.
|
||||
|
||||
### Contents
|
||||
|
||||
[About this sample](#about-this-sample)<br/>
|
||||
[Before you begin](#before-you-begin)<br/>
|
||||
[Run this sample](#run-this-sample)<br/>
|
||||
[Sample details](#sample-details)<br/>
|
||||
[Disclaimers](#disclaimers)<br/>
|
||||
[Related links](#related-links)<br/>
|
||||
|
||||
<a name=about-this-sample></a>
|
||||
|
||||
## About this sample
|
||||
|
||||
1. **Applies to:** SQL Server 2016 Express, Windows Server 2016
|
||||
5. **Authors:** Perry Skountrianos [perrysk-msft]
|
||||
|
||||
<a name=before-you-begin></a>
|
||||
|
||||
## Before you begin
|
||||
|
||||
To run this sample, you need the following prerequisites.
|
||||
|
||||
**Software prerequisites:**
|
||||
|
||||
You can run the container with the following command.
|
||||
(Note the you'll need Windows Server 2016)
|
||||
|
||||
````
|
||||
docker run -d -p 1433:1433 -v C:/temp/:C:/temp/ --env sa_password=<YOUR SA PASSWORD> --env attach_dbs="<DB-JSON-CONFIG>" microsoft/mssql-server-2016-express-windows
|
||||
````
|
||||
|
||||
- **-p HostPort:containerPort** is for port-mapping a container network port to a host port.
|
||||
- **-v HostPath:containerPath** is for mounting a folder from the host inside the container.
|
||||
|
||||
This can be used for saving database outside of the container.
|
||||
|
||||
- **-it** can be used to show the verbose output of the SQL startup script.
|
||||
|
||||
Use this to debug the container in case of issues.
|
||||
|
||||
<a name=run-this-sample></a>
|
||||
|
||||
## Run this sample
|
||||
|
||||
The image provides two environment variables to optionally set: </br>
|
||||
- **sa_password**: Sets the sa password and enables the sa login
|
||||
- **attach_dbs**: The configuration for attaching custom DBs (.mdf, .ldf files).
|
||||
|
||||
This should be a JSON string, in the following format (note the use of SINGLE quotes!)
|
||||
```
|
||||
[
|
||||
{
|
||||
'dbName': 'MaxDb',
|
||||
'dbFiles': ['C:\\temp\\maxtest.mdf',
|
||||
'C:\\temp\\maxtest_log.ldf']
|
||||
},
|
||||
{
|
||||
'dbName': 'PerryDb',
|
||||
'dbFiles': ['C:\\temp\\perrytest.mdf',
|
||||
'C:\\temp\\perrytest_log.ldf']
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
This is an array of databases, which can have zero to N databases.
|
||||
|
||||
Each consisting of:
|
||||
- **dbName**: The name of the database
|
||||
- **dbFiles**: An array of one or many absolute paths to the .MDF and .LDF files.
|
||||
|
||||
**Note:**
|
||||
The path has double backslashes for escaping!
|
||||
The path refers to files **within the container**. So make sure to include them in the image or mount them via **-v**!
|
||||
|
||||
|
||||
This example shows all parameters in action:
|
||||
```
|
||||
docker run -p 1433:1433 -v C:/temp/:C:/temp/ --env attach_dbs="[{'dbName':'MaxTest','dbFiles':['C:\\temp\\maxtest.mdf','C:\\temp\\maxtest_log.
|
||||
ldf']}]" microsoft/mssql-server-2016-express-windows
|
||||
```
|
||||
|
||||
<a name=sample-details></a>
|
||||
|
||||
## Sample details
|
||||
|
||||
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.
|
||||
- Collation: SQL_Latin1_General_CP1_CI_AS
|
||||
- SQL Instance Name: SQLEXPRESS
|
||||
- Root Directory: C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL
|
||||
- Language: English (United Stated)
|
||||
|
||||
<a name=disclaimers></a>
|
||||
|
||||
## Disclaimers
|
||||
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.
|
||||
|
||||
<a name=related-links></a>
|
||||
|
||||
## Related Links
|
||||
<!-- Links to more articles. Remember to delete "en-us" from the link path. -->
|
||||
|
||||
For more information, see these articles:
|
||||
- [Windows Containers] (https://msdn.microsoft.com/en-us/virtualization/windowscontainers/about/about_overview)
|
||||
- [Windows-based containers: Modern app development with enterprise-grade control] (https://www.youtube.com/watch?v=Ryx3o0rD5lY&feature=youtu.be)
|
||||
- [Windows Containers: What, Why and How] (https://channel9.msdn.com/Events/Build/2015/2-704)
|
||||
- [SQL Server in Windows Containers] (https://blogs.msdn.microsoft.com/sqlserverstorageengine/2016/03/21/sql-server-in-windows-containers/#comments)
|
||||
@@ -1,46 +0,0 @@
|
||||
# The script sets the sa password and start the SQL Service
|
||||
# Also it attaches additional database from the disk
|
||||
# The format for attach_dbs
|
||||
|
||||
param(
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$sa_password,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$attach_dbs
|
||||
)
|
||||
|
||||
# start the service
|
||||
Write-Verbose "Starting SQL Server"
|
||||
start-service MSSQL`$SQLEXPRESS
|
||||
|
||||
if($sa_password -ne "_"){
|
||||
Write-Verbose "Changing SA login credentials"
|
||||
$sqlcmd = "ALTER LOGIN sa with password=" +"'" + $sa_password + "'" + ";ALTER LOGIN sa ENABLE;"
|
||||
Invoke-Sqlcmd -Query $sqlcmd -ServerInstance ".\SQLEXPRESS"
|
||||
}
|
||||
|
||||
$attach_dbs_cleaned = $attach_dbs.TrimStart('\\').TrimEnd('\\')
|
||||
|
||||
$dbs = $attach_dbs_cleaned | ConvertFrom-Json
|
||||
|
||||
if ($null -ne $dbs -And $dbs.Length -gt 0){
|
||||
Write-Verbose "Attaching $($dbs.Length) database(s)"
|
||||
Foreach($db in $dbs)
|
||||
{
|
||||
$files = @();
|
||||
Foreach($file in $db.dbFiles)
|
||||
{
|
||||
$files += "(FILENAME = N'$($file)')";
|
||||
}
|
||||
|
||||
$files = $files -join ","
|
||||
$sqlcmd = "sp_detach_db $($db.dbName);CREATE DATABASE $($db.dbName) ON $($files) FOR ATTACH ;"
|
||||
|
||||
Write-Verbose "Invoke-Sqlcmd -Query $($sqlcmd) -ServerInstance '.\SQLEXPRESS'"
|
||||
Invoke-Sqlcmd -Query $sqlcmd -ServerInstance ".\SQLEXPRESS"
|
||||
}
|
||||
}
|
||||
|
||||
Write-Verbose "Started SQL Server."
|
||||
while ($true) { Start-Sleep -Seconds 3600 }
|
||||
@@ -1,28 +0,0 @@
|
||||
# mssql server 2016 vNext image
|
||||
FROM microsoft/windowsservercore
|
||||
|
||||
# maintainer for image metadata
|
||||
MAINTAINER Perry Skountrianos
|
||||
|
||||
# set environment variables
|
||||
ENV sql_vnext_download_url "https://go.microsoft.com/fwlink/?linkid=829176"
|
||||
|
||||
ENV sa_password _
|
||||
ENV attach_dbs "[]"
|
||||
ENV ACCEPT_EULA _
|
||||
|
||||
# make install files accessible
|
||||
COPY . /
|
||||
WORKDIR /
|
||||
|
||||
# download and install Microsoft SQL Server vNext in one step
|
||||
RUN powershell -Command (New-Object System.Net.WebClient).DownloadFile('%sql_vnext_download_url%', 'sqlvnext.exe') && /sqlvnext.exe /qs /x:setup && /setup/setup.exe /q /ACTION=Install /INSTANCENAME=SQL /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT="NT AUTHORITY\System" /SQLSYSADMINACCOUNTS="BUILTIN\ADMINISTRATORS" /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS && del /F /Q sqlvnext.exe && rd /q /s setup
|
||||
|
||||
RUN powershell -Command \
|
||||
set-strictmode -version latest ; \
|
||||
stop-service MSSQL`$SQL ; \
|
||||
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQL\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; \
|
||||
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQL\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; \
|
||||
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQL\mssqlserver\' -name LoginMode -value 2 ;
|
||||
|
||||
CMD powershell ./start -sa_password %sa_password% -ACCEPT_EULA %ACCEPT_EULA% -attach_dbs \"%attach_dbs%\" -Verbose
|
||||
@@ -1,110 +0,0 @@
|
||||
# mssql-server-windows
|
||||
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.
|
||||
|
||||
### Contents
|
||||
|
||||
[About this sample](#about-this-sample)<br/>
|
||||
[Before you begin](#before-you-begin)<br/>
|
||||
[Run this sample](#run-this-sample)<br/>
|
||||
[Sample details](#sample-details)<br/>
|
||||
[Disclaimers](#disclaimers)<br/>
|
||||
[Related links](#related-links)<br/>
|
||||
|
||||
<a name=about-this-sample></a>
|
||||
|
||||
## About this sample
|
||||
|
||||
1. **Applies to:** SQL Server vNext, Windows Server 2016, Windows 10
|
||||
5. **Authors:** Perry Skountrianos [perrysk-msft]
|
||||
|
||||
<a name=before-you-begin></a>
|
||||
|
||||
## Before you begin
|
||||
|
||||
To run this sample, you need the following prerequisites.
|
||||
|
||||
**Software prerequisites:**
|
||||
|
||||
You can run the container with the following command.
|
||||
(Note the you'll need Windows Server 2016 or Windows 10)
|
||||
|
||||
````
|
||||
docker run -d -p 1433:1433 -v C:/temp/:C:/temp/ -e sa_password=<YOUR SA PASSWORD> -e ACCEPT_EULA=Y -e attach_dbs="<DB-JSON-CONFIG>" microsoft/mssql-server-windows
|
||||
````
|
||||
|
||||
- **-p HostPort:containerPort** is for port-mapping a container network port to a host port.
|
||||
- **-v HostPath:containerPath** is for mounting a folder from the host inside the container.
|
||||
|
||||
This can be used for saving database outside of the container.
|
||||
|
||||
- **-it** can be used to show the verbose output of the SQL startup script.
|
||||
|
||||
Use this to debug the container in case of issues.
|
||||
|
||||
<a name=run-this-sample></a>
|
||||
|
||||
## Run this sample
|
||||
|
||||
The image provides two environment variables to optionally set: </br>
|
||||
- **accepot_eula**: Confirms acceptance of the end user licensing agreement found [here](http://go.microsoft.com/fwlink/?LinkId=746388)
|
||||
- **sa_password**: Sets the sa password and enables the sa login
|
||||
- **attach_dbs**: The configuration for attaching custom DBs (.mdf, .ldf files).
|
||||
|
||||
This should be a JSON string, in the following format (note the use of SINGLE quotes!)
|
||||
```
|
||||
[
|
||||
{
|
||||
'dbName': 'MaxDb',
|
||||
'dbFiles': ['C:\\temp\\maxtest.mdf',
|
||||
'C:\\temp\\maxtest_log.ldf']
|
||||
},
|
||||
{
|
||||
'dbName': 'PerryDb',
|
||||
'dbFiles': ['C:\\temp\\perrytest.mdf',
|
||||
'C:\\temp\\perrytest_log.ldf']
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
This is an array of databases, which can have zero to N databases.
|
||||
|
||||
Each consisting of:
|
||||
- **dbName**: The name of the database
|
||||
- **dbFiles**: An array of one or many absolute paths to the .MDF and .LDF files.
|
||||
|
||||
**Note:**
|
||||
The path has double backslashes for escaping!
|
||||
The path refers to files **within the container**. So make sure to include them in the image or mount them via **-v**!
|
||||
|
||||
|
||||
This example shows all parameters in action:
|
||||
```
|
||||
docker run -d -p 1433:1433 -v C:/temp/:C:/temp/ -e sa_password=<YOUR SA PASSWORD> -e ACCEPT_EULA=Y -e attach_dbs="[{'dbName':'SampleDB','dbFiles':['C:\\temp\\sampledb.mdf','C:\\temp\\sampledb_log.
|
||||
ldf']}]" microsoft/mssql-server-windows
|
||||
```
|
||||
|
||||
<a name=sample-details></a>
|
||||
|
||||
## Sample details
|
||||
|
||||
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.
|
||||
- Collation: SQL_Latin1_General_CP1_CI_AS
|
||||
- SQL Instance Name: SQLEXPRESS
|
||||
- Root Directory: C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL
|
||||
- Language: English (United Stated)
|
||||
|
||||
<a name=disclaimers></a>
|
||||
|
||||
## Disclaimers
|
||||
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.
|
||||
|
||||
<a name=related-links></a>
|
||||
|
||||
## Related Links
|
||||
<!-- Links to more articles. Remember to delete "en-us" from the link path. -->
|
||||
|
||||
For more information, see these articles:
|
||||
- [Windows Containers] (https://msdn.microsoft.com/en-us/virtualization/windowscontainers/about/about_overview)
|
||||
- [Windows-based containers: Modern app development with enterprise-grade control] (https://www.youtube.com/watch?v=Ryx3o0rD5lY&feature=youtu.be)
|
||||
- [Windows Containers: What, Why and How] (https://channel9.msdn.com/Events/Build/2015/2-704)
|
||||
- [SQL Server in Windows Containers] (https://blogs.msdn.microsoft.com/sqlserverstorageengine/2016/03/21/sql-server-in-windows-containers/#comments)
|
||||
@@ -1,57 +0,0 @@
|
||||
# The script sets the sa password and start the SQL Service
|
||||
# Also it attaches additional database from the disk
|
||||
# The format for attach_dbs
|
||||
|
||||
param(
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$sa_password,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$ACCEPT_EULA,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$attach_dbs
|
||||
)
|
||||
|
||||
|
||||
if($ACCEPT_EULA -ne "Y" -And $ACCEPT_EULA -ne "y"){
|
||||
Write-Verbose "ERROR: You must accept the End User License Agreement before this container can start."
|
||||
Write-Verbose "Set the environment variable ACCEPT_EULA to 'Y' if you accept the agreement."
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
# start the service
|
||||
Write-Verbose "Starting SQL Server"
|
||||
start-service MSSQL`$SQL
|
||||
|
||||
if($sa_password -ne "_"){
|
||||
Write-Verbose "Changing SA login credentials"
|
||||
$sqlcmd = "ALTER LOGIN sa with password=" +"'" + $sa_password + "'" + ";ALTER LOGIN sa ENABLE;"
|
||||
Invoke-Sqlcmd -Query $sqlcmd -ServerInstance ".\SQL"
|
||||
}
|
||||
|
||||
$attach_dbs_cleaned = $attach_dbs.TrimStart('\\').TrimEnd('\\')
|
||||
|
||||
$dbs = $attach_dbs_cleaned | ConvertFrom-Json
|
||||
|
||||
if ($null -ne $dbs -And $dbs.Length -gt 0){
|
||||
Write-Verbose "Attaching $($dbs.Length) database(s)"
|
||||
Foreach($db in $dbs)
|
||||
{
|
||||
$files = @();
|
||||
Foreach($file in $db.dbFiles)
|
||||
{
|
||||
$files += "(FILENAME = N'$($file)')";
|
||||
}
|
||||
|
||||
$files = $files -join ","
|
||||
$sqlcmd = "sp_detach_db $($db.dbName);CREATE DATABASE $($db.dbName) ON $($files) FOR ATTACH ;"
|
||||
|
||||
Write-Verbose "Invoke-Sqlcmd -Query $($sqlcmd) -ServerInstance '.\SQL'"
|
||||
Invoke-Sqlcmd -Query $sqlcmd -ServerInstance ".\SQL"
|
||||
}
|
||||
}
|
||||
|
||||
Write-Verbose "Started SQL Server."
|
||||
while ($true) { Start-Sleep -Seconds 3600 }
|
||||
@@ -1,7 +1,4 @@
|
||||
## Windows Containers
|
||||
This includes samples for setting up mssql-server in Windows Containers. Currently it includes the following:
|
||||
- __[mssql-server-2016-SP1-express-windows] (mssql-server-2016-express-sp1-windows/)__
|
||||
- __[mssql-server-2016-express-windows] (mssql-server-2016-express-windows/)__
|
||||
- __[mssql-server-2014-express-windows] (mssql-server-2014-express-windows/)__
|
||||
- __[mssql-server-vNext-windows] (mssql-server-windows/)__
|
||||
|
||||
Moved here: [Microsoft/mssql-docker](https://github.com/Microsoft/mssql-docker/blob/master/windows/README.md)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user