Hi,
I have created a new SQL Server Express image for Windows Server 2019
I test the image on a Windows Server 2019 Vm on Azure in process isolation (Not Hyper-V).
The Sql Server service starts well when I run the image with a Docker Run command.
The same image with a Docker-Compose run or up + same parameters return an error when the service starts:
I struggle since days to find the reason without success.
Anyone could give me some hints on the reason ?
The DockerFile:
FROM mcr.microsoft.com/windows/servercore:ltsc2019
USER ContainerAdministrator
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
# see https://support.microsoft.com/en-us/help/4462262 for latest CU
ARG DOWNLOAD_URL="https://go.microsoft.com/fwlink/?linkid=829176"
ENV sa_password="_" `
sa_password_path="C:\ProgramData\Docker\secrets\sa-password"
RUN Invoke-WebRequest -Uri $env:DOWNLOAD_URL -OutFile sqlexpress.exe; `
Start-Process -Wait -FilePath .\sqlexpress.exe -ArgumentList /qs, /x:setup ; `
.\setup\setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT='NT AUTHORITY\System' /SQLSYSADMINACCOUNTS='BUILTIN\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS ; `
Remove-Item -Recurse -Force sqlexpress.exe, setup
RUN Stop-Service MSSQL`$SQLEXPRESS ; `
Set-ItemProperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; `
Set-ItemProperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; `
Set-ItemProperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver\' -name LoginMode -value 2 ;
COPY start.ps1 /
CMD .\start -sa_password $env:sa_password -Verbose
The Docker-Compose:
mssql:
container_name: mssql
image: ${DOCKER_REGISTRY-}mssql
environment:
ACCEPT_EULA: Y
SA_PASSWORD: "yourStrong(!)Password"
build:
context: sqlserver
dockerfile: Dockerfile
ports:
- "1433:1433/tcp"
#tty: true #had to remove it to avoid another null character error
volumes:
- .db:C:/Program Files/Microsoft SQL Server/MSSQL14.SQLEXPRESS/MSSQL/DATA
start.ps1:
param(
[Parameter(Mandatory=$false)]
[string]$sa_password
)
Write-Verbose "Starting SQL Server"
start-service MSSQL`$SQLEXPRESS
if($sa_password -eq "_") {
$secretPath = $env:sa_password_path
if (Test-Path $secretPath) {
$sa_password = Get-Content -Raw $secretPath
}
else {
Write-Verbose "WARN: Using default SA password, secret file not found at: $secretPath"
}
}
if($sa_password -ne "_")
{
Write-Verbose "Changing SA login credentials..."
$sqlcmd = "ALTER LOGIN sa with password=" +"'" + $env:sa_password + "'" + ";ALTER LOGIN sa ENABLE;"
& sqlcmd -Q $sqlcmd
}
Write-Verbose "Started SQL Server."
$lastCheck = (Get-Date).AddSeconds(-2)
while ($true)
{
Get-EventLog -LogName Application -Source "MSSQL*" -After $lastCheck | Select-Object TimeGenerated, EntryType, Message
$lastCheck = Get-Date
Start-Sleep -Seconds 2
}
The Error:
Attaching to mssql
mssql | VERBOSE: Starting SQL Server
mssql | start-service : Failed to start service ‘SQL Server (SQLEXPRESS)
mssql | (MSSQL$SQLEXPRESS)’.
mssql | At C:\start.ps1:7 char:1
mssql | + start-service MSSQL`$SQLEXPRESS
mssql | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mssql | + CategoryInfo : OpenError: (System.ServiceProcess.ServiceControl
mssql | ler:ServiceController) [Start-Service], ServiceCommandException
mssql | + FullyQualifiedErrorId : StartServiceFailed,Microsoft.PowerShell.Commands
mssql | .StartServiceCommand
mssql |
mssql exited with code 1
*ps: do anyone knows a standard SQL Image witch works in a Win2019 process isolation.
Any image I pull give the
“The container operating system does not match the host operating system”
Thanks in advance
-Vince