Skip to content

Commit 3358668

Browse files
committed
Updated DockerFile: User specified sa password
1 parent cb60c06 commit 3358668

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

samples/manage/windows-containers/mssql-server-2014-express-windows/dockerfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ FROM microsoft/dotnet35
1010
MAINTAINER Perry Skountrianos
1111

1212
# set environment variables
13-
ENV SQL_EXPRESS_DOWNLOAD_URL "https://download.microsoft.com/download/1/5/6/156992E6-F7C7-4E55-833D-249BD2348138/ENU/x64/SQLEXPR_x64_ENU.exe"
14-
ENV SQL_SERVER_SA_PASSWORD "Password1"
13+
ENV sql_express_download_url "https://download.microsoft.com/download/1/5/6/156992E6-F7C7-4E55-833D-249BD2348138/ENU/x64/SQLEXPR_x64_ENU.exe"
14+
ENV sa_password _
1515

16-
# set working directory
16+
# make install files accessible
17+
COPY . /
1718
WORKDIR /
1819

1920
# download and install Microsoft SQL 2014 Express Edition in one step
20-
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
21+
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
2122

2223
RUN powershell -Command \
2324
set-strictmode -version latest ; \
24-
stop-service MSSQL`$SQLEXPRESS ; \
25+
stop-service MSSQL`$%sqlinstance% ; \
2526
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql12.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; \
2627
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql12.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; \
27-
start-service MSSQL`$SQLEXPRESS
28+
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql12.SQLEXPRESS\mssqlserver\' -name LoginMode -value 2 ;
2829

29-
CMD powershell -Command while ($true) { Start-Sleep -Seconds 3600 }
30-
EXPOSE 1433
30+
CMD powershell ./start %sa_password%

samples/manage/windows-containers/mssql-server-2014-express-windows/readme.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# mssql-server-2014-express-windows
2-
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.
1+
# mssql-server-2014-express-windows
2+
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.
33

44
Note: This dockerfile is based on Buc Rogers' work that can be found [here] (https://github.com/brogersyh/Dockerfiles-for-windows/tree/master/sqlexpress)
55

@@ -35,16 +35,15 @@ To run this sample, you need the following prerequisites.
3535

3636
## Run this sample
3737
Use the Dockerfile and execute the following two commands to build and run sqlexpress:
38-
1. docker build -t sqlexpress .
39-
2. docker run -it -p 1433:1433 sqlexpress cmd
38+
1. docker build --env sa_password=<YOUR_SA_PASSWORD> <IMAGE NAME> .
39+
2. docker run -it -p 1433:1433 <IMAGE NAME> cmd
4040

4141
<a name=sample-details></a>
4242

4343
## Sample details
4444

4545
**High Level Description**
4646
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.
47-
- sa password: Password1
4847
- Collation: SQL_Latin1_General_CP1_CI_AS
4948
- SQL Instance Name: SQLEXPRESS
5049
- Root Directory: C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# The script sets the sa password and start the SQl Service
2+
3+
param(
4+
[Parameter(Mandatory=$false)]
5+
[string]$sa_password
6+
)
7+
8+
# start the service
9+
start-service MSSQL`$SQLEXPRESS
10+
11+
12+
if($sa_password -ne "_"){
13+
$sqlcmd = "ALTER LOGIN sa with password=" +"'" + $sa_password + "'" + ";ALTER LOGIN sa ENABLE;"
14+
Invoke-Sqlcmd -Query $sqlcmd -ServerInstance ".\SQLEXPRESS"
15+
}
16+
17+
while ($true) { Start-Sleep -Seconds 3600 }

0 commit comments

Comments
 (0)