Last active
April 30, 2019 17:50
-
-
Save SQLvariant/ebe7fa49216badb6b53339818ca1eda9 to your computer and use it in GitHub Desktop.
simple dockerfile for building a SQL-on-Linux container. Place this file in your c:\temp directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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