sql-serverlocaldbwindows-server-2019redgatewindows-server-container

Install SQL Server LocalDB on Server Core 2019 in Docker container


Within a Docker container (image = mcr.microsoft.com/windows/servercore:ltsc2019), I have downloaded the SQL Server Express 2019 installer.

I have successfully downloaded the LocalDB msi with:

SQL2019-SSEI-Expr.exe /Action=Download /MediaType=LocalDB /Quiet

The file is downloaded to:

C:\Users\ContainerAdministrator\Downloads\en-us\SqlLocalDB.msi

However... running msiexec fails without any error messages. After navigating to the path mentioned above, I execute:

msiexec.exe /qb /i .\SqlLocalDB.msi IAcceptSqlLocalDBLicenseTerms=YES

The command immediately drops back to the command line after zero delay. Nothing ever gets installed.

What am I missing?

Edit: I'm trying to use LocalDB because this will eventually be an Azure Pipelines build agent. We use Redgate's "SqlChangeAutomation" powershell tools which uses LocalDB.

Edit 2: Not sure if this is progress yet, however... I mucked around with msiexec logging for a bit and discovered I could run it with the /a flag instead of /i and get it to successfully install.

msiexec.exe /qn /a SqlLocalDB.msi IAcceptSqlServerLicenseTerms=YES /L*V "C:\installers\SQL\install.log"

Unfortunately, however, upon navigating to C:\Program Files\Microsoft SQL Server\150\tools\binn and running SqlLocalDB.exe info, I get this:

Call to LocalDBFormatMessage failed. Error code returned:
2311389462.
Error in LocalDBFormatMessage! Error code returned:
2311389462.

Solution

  • SQL LocalDB requires the Visual C++ redistributables, else many things won't go right (my problem was that SqlWriter service wouldn't create during install at all).

    EDIT: it seems that I can use chocolatey to install the vc_redist and a older version of localdb. (Filing ticket to ask for the sqllocaldb package to be updated to 2019) so that would simplify things for most people. Keeping raw arguments/commands below just in case though.

    My powershell steps for exact arguments (assuming you collect required files):

    1. start-process .\VC_redist.x64.exe -Wait -ArgumentList @('/install','/norestart','/passive') Note I am using the redist from https://aka.ms/vs/16/release/vc_redist.x64.exe which should be the 2019, but spattering of comments say I should have used either the one in the SQL installer package, or some 2015 version. However neither of those "worked" for me in the containers, but that could have been me invoking them wrong. Besides which, further packages I need to install want 2019 anyways.
    2. start-process msiexec -Wait -ArgumentList @('/i','SqlLocalDB.msi','/qn','/norestart','/L*V','install.log','IACCEPTSQLLOCALDBLICENSETE RMS=YES') Note that "/i" instead of "/a" worked correctly at this point, and the "/norestart" option. This was found from the choco localdb command source.

    Useful powershell snippet to get some event logs (change "System" for "Application" for others) that helped me puzzle things out since no event-viewer in container: get-eventlog -LogName System -After (Get-Date).AddMinutes(-5) | ? {-not $_.Source.Contains("DCOM") } |?{-not $_.Message.Contains("depends on the Background Tasks Infrastructure Service")}| Format-List This and inspecting the "install.log" line-by-line from the SqlLocalDB.msi were what eventually led me on the right track.