Categories Docker, Microsoft SQL, Software Tags Docker, Microsoft, PowerShell, SQL
If you are lucky, you will now have a running SQL Server 2019 Developer Edition and you can connect directly to it with Microsoft SQL Server Management Studio directly on the host running Docker (use “SQL Server Authentication” with host: “localhost”, login: “sa” and the password stated above). …and then you have to run these docker commands (replace “ ” with the path to the above mentioned two files: dockerfile and start.ps1 – and “ ” with the sa-password you want): docker build -memory 4g -tag dabbler/mssql-server-windows-developer:winsrv1809-sql2019 " "ĭocker run -name SQLServer2019 -e ACCEPT_EULA=Y -e sa_password= -p 1433:1433 -d dabbler/mssql-server-windows-developer:winsrv1809-sql2019 Get-EventLog -LogName Application -Source "MSSQL*" -After $lastCheck | Select-Object TimeGenerated, EntryType, Message Write-Verbose "Invoke-Sqlcmd -Query $($sqlcmd)" $sqlcmd = "IF EXISTS (SELECT 1 FROM SYS.DATABASES WHERE NAME = '" + $($db.dbName) + "') BEGIN EXEC sp_detach_db END CREATE DATABASE ON $($files) FOR ATTACH " Write-Verbose "Attaching $($dbs.Length) database(s)" If ($null -ne $dbs -And $dbs.Length -gt 0) $dbs = $attach_dbs_cleaned | ConvertFrom-Json $sqlcmd = "ALTER LOGIN sa with password=" +"'" + $sa_password + "'" + " ALTER LOGIN sa ENABLE " Write-Verbose "Changing SA login credentials" Write-Verbose "WARN: Using default SA password, secret file not found at: $secretPath" $sa_password = Get-Content -Raw $secretPath Write-Verbose "Set the environment variable ACCEPT_EULA to 'Y' if you accept the agreement."
Write-Verbose "ERROR: You must accept the End User License Agreement before this container can start." If($ACCEPT_EULA -ne "Y" -And $ACCEPT_EULA -ne "y") # Also it attaches additional database from the disk # The script sets the sa password and start the SQL Service \start -sa_password $env:sa_password -ACCEPT_EULA $env:ACCEPT_EULA -attach_dbs \"$env:attach_dbs\" -Verbose Set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql15.MSSQLSERVER\mssqlserver\' -name LoginMode -value 2
Set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql15.MSSQLSERVER\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 \ Set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql15.MSSQLSERVER\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' \ Remove-Item -Recurse -Force SQL.exe, SQL.box, setup \setup\setup.exe /q /ACTION=Install /INSTANCENAME=MSSQLSERVER /FEATURES=SQLEngine /UPDATEENABLED=1 /SQLSVCACCOUNT='NT AUTHORITY\NETWORK SERVICE' /SQLSYSADMINACCOUNTS='BUILTIN\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS /SQLMAXDOP=1 /SQLBACKUPDIR='C:\Server\MSSQL\Backup' /SQLUSERDBDIR='C:\Server\MSSQL\DB' /SQLUSERDBLOGDIR='C:\Server\MSSQL\DB' \ Invoke-WebRequest -Uri $env:exe -OutFile SQL.exe \ RUN Invoke-WebRequest -Uri $env:box -OutFile SQL.box \ Sa_password_path="C:\ProgramData\Docker\secrets\sa-password" Let’s roll with this – first you need to create these two files:įROM /windows/servercore:1809
This will also solve that as this image is based on the “/windows/servercore:1809” Windows Server image.Įnough notes for now :-). Note 3: If you try to use the official Microsoft SQL Server Developer Edition image and you get the error “The container operating system does not match the host operating system.”, it is probably because that image is not Windows Server 1809 compatible. Note 2: We are only taking about minor changes here – so I’m not in ANY way trying to claim credits for these scripts – all credits goes to the original author for these scripts – see the above mentioned official link! Unfortunately this has not been updated to run Windows ServerCore 1890 and Microsoft SQL Server 2019 – so this is what this blog post is about… Note: This work is based on the “Official Microsoft repository for SQL Server in Docker resources” found here: