Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
simple dockerfile for building a SQL-on-Linux container. Place this file in your c:\temp directory
<# Step 0)
Put the dockerfile & AdventureWorks2016.bak into your c:\temp
$dockerfileURL = "";
$dockerfile = c:\temp\BuildContainer_FromImage.ps1;
Invoke-WebRequest -Uri $dockerfileURL -OutFile $dockerfile;
Copy-Item -Path "$($Home)\Downloads\AdventureWorks2016.bak" -Destination C:\temp
<# First, build the image #>
docker build -t solwadw2016 c:\temp
<# Once that builds successfully, create a container from it. #>
docker run -d -p 10003:1433 --name testcontainer03 solwadw2016
<# Enter the password when prompted,
keep running Invoke-Sqlcmd until you see AdventureWorks2016
$solwadw2016Cred = (Get-Credential sa)
Invoke-Sqlcmd -ServerInstance 'localhost,10003' -Credential $solwadw2016Cred -Query "SELECT name from sys.databases"
FROM microsoft/mssql-server-linux
RUN mkdir /var/opt/sqlserver
COPY AdventureWorks2016.bak /var/opt/sqlserver
HEALTHCHECK --interval=10s \
CMD /opt/mssql/bin/sqlserver & \
/opt/mssql-tools/bin/sqlcmd -S . -U sa -P Test1234 \
-Q "RESTORE DATABASE [AdventureWorks2016] FROM DISK = N'/var/opt/sqlserver/AdventureWorks2016.bak' WITH FILE = 1, MOVE N'AdventureWorks2016_Data' TO N'/var/opt/mssql/data/AdventureWorks2016_Data.mdf', MOVE N'AdventureWorks2016_Log' TO N'/var/opt/mssql/data/AdventureWorks2016_Log.ldf', NOUNLOAD, STATS = 5"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.