Skip to content

Instantly share code, notes, and snippets.

Embed
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 = "https://gist.githubusercontent.com/SQLvariant/ebe7fa49216badb6b53339818ca1eda9/raw/ded3e7f988309d311b6f389257e499cb66d5dd39/dockerfile";
$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
ENV ACCEPT_EULA=Y
ENV SA_PASSWORD=Test1234
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.