SQL Server in Windows Containers

03/21/2016

2 minutes to read

In this article

Windows Containers are an isolated, resource controlled, and portable operating environment. An application inside a container can run without affecting the rest of the system and vice versa. This isolation makes SQL Server in a Windows Container ideal for Rapid Test Deployment scenarios as well as Continuous Integration Processes. This blog provides a step by step guide of setting up SQL Server Express 2014 in a Windows Container by using this community-contributed Dockerfile.

Prerequisites

• System running Windows Server Technical Preview 4 or later.

• 10GB available storage for container host image, OS Base Image and setup scripts.

• Administrator permissions on the system.

Setup a VM or a physical machine as a Windows Container Host

Step 1: Start a PowerShell session as administrator. This can be done by running the following command from the command line.

PS C:\> powershell.exe

Step 2: Use the following command to download the setup script. Note: The script can also be manually downloaded from this location - Configuration Script.

wget -uri https://aka.ms/tp4/Install-ContainerHost -OutFile C:\Install-ContainerHost.ps1

Step 3: After the download completes, execute the script.

PS C:\> powershell.exe -NoProfile C:\Install-ContainerHost.ps1

With these steps completed your system should be ready for Windows Containers. You can follow this link to read the full article that describes more on setting up a VM or a physical machine as a Windows Container Host.

Installing SQL Server Express 2014 in a Windows Container

Step 1: Copy all files from this community-contributed Dockerfile locally into your c:\sqlexpress folder.

Note: All files were provided by brogersyh . The Dockerfile contains all the SQL Server configuration settings (ports, passwords etc.) that you can customize if needed.

Step 2: Start a PowerShell session and run the following command:

docker build -t sqlexpress .

Starting SQL Server

Step 1: Start a PowerShell session and run the following command:

docker run -it -p 1433:1433 sqlexpress cmd

Step 2: Enter PowerShell in the Container Window by typing:

Powershell

Step 3: Start SQL Server by running the following PS Script (downloaded from step2):

./start

Step 4: Verify that SQL Server is running with the following command:

get-service *sql*

Next Steps

We are currently working on testing and publishing SQL Server Container Images that could speed up the process of getting started with SQL Server in Windows Containers significantly. Stay tuned for an update!

Further Reading

Windows Containers Overview Windows-based containers: Modern app development with enterprise-grade control.

Windows Containers: What, Why and How