skip to Main Content

Context:
Linux SQL Docker containers don’t support FileStreams, so this is a no-go the Database I wish to restore (which uses Varbinaries) we’re trying to remove them, but short term, we need to keep them and can’t lose the data in them or render the columns non-functional.

docker pull mcr.microsoft.com/mssql/server:2022-latest

Windows SQL Docker seems to be end of life and the repo has been taken down

microsoft/mssql-server-windows-developer

So that leaves me with one perceived option… Build my own Windows Container and install SQL Server manually. So using SQL Server Core 2019

mcr.microsoft.com/windows/servercore

From here I tried to source examples of this being done by others, to limited success. This gave me a good basis of a DockerFile to start from:

Setup Guide I was following

#Step 1: Start from base image mcr.microsoft.com/windows/servercore
FROM mcr.microsoft.com/windows/servercore
#Step 2: Create temporary directory to hold SQL Server 2016 installation files
RUN powershell -Command (mkdir C:SQL2016Dev_SP2)
#Step 3: Copy SQL Server 2016 installation files from the host to the container image
COPY SQL2016Dev_SP2 C:/SQL2016Dev_SP2
#Step 4: Install SQL Server 2016 via command line
RUN C:/SQL2016Dev_SP2/SETUP.exe /Q /ACTION=INSTALL /FEATURES=SQLENGINE /INSTANCENAME=MSSQLSERVER 
/SECURITYMODE=SQL /SAPWD="y0urSecUr3PAssw0rd" /SQLSVCACCOUNT="NT AUTHORITYSystem" 
/AGTSVCACCOUNT="NT AUTHORITYSystem" /SQLSYSADMINACCOUNTS="BUILTINAdministrators" 
/IACCEPTSQLSERVERLICENSETERMS=1 /TCPENABLED=1 /UPDATEENABLED=False
#Step 5: Set SQL Server service to automatic
RUN powershell -Command (Set-Service MSSQLSERVER -StartupType Automatic)
#Step 6: Remove SQL Server installation media folder
RUN powershell -Command (Remove-Item -Path C:/SQL2016Dev_SP2 -Recurse -Force) 
#Step 7: Switch shell to PowerShell in preparation for running script Start.ps1
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
#Step 8: Copy Start.ps1 to image on root directory
COPY start.ps1 /
#Step 9: Set current working directory for script execution
WORKDIR /
#Step 10: Run PowerShell script Start.ps1, passing the -ACCEPT_EULA parameter with a value of Y
CMD .start.ps1 -ACCEPT_EULA "Y" -Verbose

Start.ps1 source


#Step 4 gave me issues in that many of the parameters in step 4 aren’t supported

Reference list of SQL accepted params from Microsoft for SQL 2022

The setting 'features' specified is not recognized.

This is repeat for: ‘instancename’, ‘securitymode’, ‘sapwd’, ‘sqlsvcaccount’, ‘agtsvcaccount’, ‘sqlsysadminaccounts’, ‘tcpenabled’,’updateenabled’

Using /? on the downloaded installer (sql server 2022, developer) confirms the reduced list of accepted parameters.

Stripping out the parameters leaves a Container with a SQL server install, but no SA user, meaning no user to log in with.

My goal is to have a Windows Docker container, Running SQL Server, with an account to log into for a destructible test environment.

2

Answers


  1. Chosen as BEST ANSWER

    I found that Windows Server Core 2019/2022 docker images do not have support for FILESTREAM either and any attempt to enable them in SQL server management via WMI would silently fail. So in order to achieve what I was looking to do, I would have to use a full Windows Server installation.

    Looks like I'll be taking the route of changing my VarBinaries to another structure that doesn't implement FileStreams.


  2. I was able to create SQL server image in windows container using the following instructions. Hope this can help!

    https://tobiasfenster.io/ms-sql-server-in-windows-containers

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search