SQL Server 2017 running on Windows Containers!


One of the questions which I normally get all the time whenever I talk about SQL Server and Docker is – Why you want to run SQL Server on containers?

Here is what Microsoft has to say:

“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.”

Recently I had a chance to invest sometime configuring SQL Server 2017(CTP 2) on Windows Containers, and this post will give you the step by step instructions on how to configure this.

Step 1 –

Choose Windows Server 2016 for running containers.

All my testing was done in AWS, and I picked the below AMI- Microsoft Windows Server 2016 Base with Containers

Step 2 – 

Install Docker. Run the below PS commands –

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider
Start-Service Docker

Step 3 – 

Update Windows Patches.

Step 4 – 

Do docker pull to get the Official images for Microsoft SQL Server for Windows Containers.

docker pull microsoft/mssql-server-windows

Step 5 – 

Run the container.

docker run -d -p 1433:1433 -e sa_password=<Your strong SA Password> -e ACCEPT_EULA=Y microsoft/mssql-server-windows

Step 6 – 

Run docker ps and note down the container_ID.

Run docker inspect and note down the IP of the container.

docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <Container_ID>

Step 7 – 

Connect to the SQL Server(Instance) outside the container via SQL Server Management Studio. Use the IP to connect.

*Click on the image below for better resolution.

 

Conclusion :

That’s pretty much it. Within 7 steps you are running SQL Server 2017 on Windows Containers. Its super lightweight and easy to spin up. Perfect fit for a CI pipeline.

Thanks for reading, and keep watching this space for more(container goodness!).