mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
Updated DockerFile: User specified sa password
This commit is contained in:
@@ -10,21 +10,21 @@ FROM microsoft/dotnet35
|
|||||||
MAINTAINER Perry Skountrianos
|
MAINTAINER Perry Skountrianos
|
||||||
|
|
||||||
# set environment variables
|
# 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 sql_express_download_url "https://download.microsoft.com/download/1/5/6/156992E6-F7C7-4E55-833D-249BD2348138/ENU/x64/SQLEXPR_x64_ENU.exe"
|
||||||
ENV SQL_SERVER_SA_PASSWORD "Password1"
|
ENV sa_password _
|
||||||
|
|
||||||
# set working directory
|
# make install files accessible
|
||||||
|
COPY . /
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
|
|
||||||
# download and install Microsoft SQL 2014 Express Edition in one step
|
# 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 /SECURITYMODE=SQL /SAPWD=%SQL_SERVER_SA_PASSWORD% /SQLSVCACCOUNT="NT AUTHORITY\System" /SQLSYSADMINACCOUNTS="BUILTIN\ADMINISTRATORS" /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS && del /F /Q sqlexpress.exe && rd /q /s setup
|
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 \
|
RUN powershell -Command \
|
||||||
set-strictmode -version latest ; \
|
set-strictmode -version latest ; \
|
||||||
stop-service MSSQL`$SQLEXPRESS ; \
|
stop-service MSSQL`$%sqlinstance% ; \
|
||||||
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 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\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; \
|
||||||
start-service MSSQL`$SQLEXPRESS
|
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql12.SQLEXPRESS\mssqlserver\' -name LoginMode -value 2 ;
|
||||||
|
|
||||||
CMD powershell -Command while ($true) { Start-Sleep -Seconds 3600 }
|
CMD powershell ./start %sa_password%
|
||||||
EXPOSE 1433
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# mssql-server-2014-express-windows
|
# mssql-server-2014-express-windows
|
||||||
The goal of this Dockerfile is to help developers get started using SQL Server 2014 Express in Windows Containers. The Dockerfile downloads and installs SQL Server 2014 Express with the default setup parameters that could be changed (if needed) after the image is installed.
|
This Dockerfile helps developers to get started using SQL Server 2014 Express in Windows Containers. The Dockerfile downloads and installs SQL Server 2014 Express with the default setup parameters that could be changed (if needed) after the image is installed.
|
||||||
|
|
||||||
Note: This dockerfile is based on Buc Rogers' work that can be found [here] (https://github.com/brogersyh/Dockerfiles-for-windows/tree/master/sqlexpress)
|
Note: This dockerfile is based on Buc Rogers' work that can be found [here] (https://github.com/brogersyh/Dockerfiles-for-windows/tree/master/sqlexpress)
|
||||||
|
|
||||||
@@ -35,8 +35,8 @@ To run this sample, you need the following prerequisites.
|
|||||||
|
|
||||||
## Run this sample
|
## Run this sample
|
||||||
Use the Dockerfile and execute the following two commands to build and run sqlexpress:
|
Use the Dockerfile and execute the following two commands to build and run sqlexpress:
|
||||||
1. docker build -t sqlexpress .
|
1. docker build --env sa_password=<YOUR_SA_PASSWORD> <IMAGE NAME> .
|
||||||
2. docker run -it -p 1433:1433 sqlexpress cmd
|
2. docker run -it -p 1433:1433 <IMAGE NAME> cmd
|
||||||
|
|
||||||
<a name=sample-details></a>
|
<a name=sample-details></a>
|
||||||
|
|
||||||
@@ -44,7 +44,6 @@ Use the Dockerfile and execute the following two commands to build and run sqlex
|
|||||||
|
|
||||||
**High Level Description**
|
**High Level Description**
|
||||||
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.
|
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.
|
||||||
- sa password: Password1
|
|
||||||
- Collation: SQL_Latin1_General_CP1_CI_AS
|
- Collation: SQL_Latin1_General_CP1_CI_AS
|
||||||
- SQL Instance Name: SQLEXPRESS
|
- SQL Instance Name: SQLEXPRESS
|
||||||
- Root Directory: C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL
|
- Root Directory: C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# The script sets the sa password and start the SQl Service
|
||||||
|
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[string]$sa_password
|
||||||
|
)
|
||||||
|
|
||||||
|
# start the service
|
||||||
|
start-service MSSQL`$SQLEXPRESS
|
||||||
|
|
||||||
|
|
||||||
|
if($sa_password -ne "_"){
|
||||||
|
$sqlcmd = "ALTER LOGIN sa with password=" +"'" + $sa_password + "'" + ";ALTER LOGIN sa ENABLE;"
|
||||||
|
Invoke-Sqlcmd -Query $sqlcmd -ServerInstance ".\SQLEXPRESS"
|
||||||
|
}
|
||||||
|
|
||||||
|
while ($true) { Start-Sleep -Seconds 3600 }
|
||||||
Reference in New Issue
Block a user