How to set up a Windows Docker Container with SQL Server? – Docker

Alexei Petrov
boot2docker sql-server

Quick Fix: Unfortunately, Windows Server Core 2019/2022 docker images do not support FILESTREAM. Consider using a full Windows Server installation or choosing a different data structure that does not require FileStreams.

The Problem:

In a Windows Docker container, setting up SQL Server necessitates a viable method. Since Linux containers lack FileStreams support and Windows containers are no longer available, creating a custom container and manually installing SQL Server is the preferred solution. However, challenges arise, such as unsupported parameters in the installation process, leading to the absence of a Service Account (SA) user. The objective is to establish a Windows Docker container with SQL Server and an accessible SA user for a disposable testing environment.

The Solutions:

Solution 1: Change VarBinaries to a different structure

The provided solution states that Windows Server Core images lack FILESTREAM support, making it impossible to enable them in SQL Server Management via WMI. To resolve this issue, the recommended approach is to modify the VarBinaries to a different structure that does not implement FileStreams. This would allow you to continue working with your database and eliminate the need for a Windows Docker container with SQL Server.

Solution 2: Utilizing Docker to Construct a Windows Container for SQL Server


Here’s a breakdown of how to build a Windows container hosting an SQL Server instance:


1. Base Image Selection: Initiate by leveraging the official Microsoft Windows Server Core image as the foundation for your container.


2. Creating a Temporary Directory: Inside the container, establish a temporary directory designated for hosting SQL Server installation files.


3. Transferring Installation Files: Copy the required SQL Server installation files from your host machine into the temporary directory within the container.


4. Installing SQL Server: Execute the SQL Server installation process using command line parameters, taking note of any modifications needed to accommodate the supported parameters for your specific SQL Server version. Remember to configure essential settings such as instance name, authentication mode, service accounts, and port settings.


5. Enabling Automatic Startup: Configure the SQL Server service to start automatically upon system boot.


6. Removing Installation Media: Once the installation is complete, remove the temporary directory containing the SQL Server installation files for a cleaner container image.


7. Switching to PowerShell Shell: Set the container’s default shell to PowerShell for executing subsequent commands.


8. Copying Startup Script: Transfer the provided "start.ps1" script into the container’s root directory. This script handles additional configuration tasks and user account creation.


9. Setting Current Directory: Designate the root directory as the current working directory for executing the startup script.


10. Executing Startup Script: Finally, run the "start.ps1" script, passing the necessary parameters for EULA acceptance and verbose output.


This process should yield a Windows container with a fully functional SQL Server instance, ready for use in your development or testing environment.


How to install SQL Server 2022 on Windows Server Core 2019/2022 docker image?

Use a full Windows Server installation instead.

How to obtain the list of accepted parameters from SQL 2022?

Use /? on the downloaded installer.

How to create a SQL server image in a windows container?

Video Explanation:

The following video, titled "How to run SQL server in a Docker container? - YouTube", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

Database Installation and Setup. Database Star · Playlist · 13:41 · Go to channel · Docker Install Microsoft SQL Server 2019 on Ubuntu 20.04 LTS.