<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1194005000700189&amp;ev=PageView&amp;noscript=1">

From Vizuri's Experts

Docker on Windows Server: Dockerize SQL

Linux based apps can use MongoDB, MySQL or PostgreSQL in the form of Docker Linux Containers. Windows-based SQL Server containers are now supported with Windows Server 2016. Let's look at how you can create and connect to a MSSQL container in Azure and Windows.

First we login to the Azure Portal and spin up a "Windows 2016 server with containers". If you are unfamiliar with this,  check out my article on "Deploying a Simple Windows Container in Azure".



Once we have created our Windows 2016 instance, we can connect to it via RDP and open a PowerShell window.  Next, we will pull down the mssql-server container image by running 'docker pull microsoft/mssql-server-windows'.  

extracting .jpg

We need to be a bit patient when we pull a windows image for the first time on this host. These are relatively large images and the download/extract process may take a while depending on the size and connection needs. 


Once the Dockerhub image pull is complete, run a container instance from the image making sure to pass in the desired SA password and accept the EULA.    

docker run -d -p 1433:1433 -e sa_password=barkmeow88!!!!! -e ACCEPT_EULA=Y microsoft/mssql-server-windows

Bark meow.jpg


After the container is run we will want to figure out the IP address of the container. To do this we will use the command "docker inspect".  Docker inspect is a useful command for to see a number of objects in Docker such as networks, images, volumes and containers.


Before we run the docker inspect we need to know the container ID. To get this, we can run the command "docker ps". This command will verify that the container is running and its container ID.

contianer id1 .jpg


So with this information we can run the command "docker inspect ff8" as only the first 3 characters matter here. You will have a different container ID than what is displayed here.Toward the bottom of the results we can find the IP address of the container , we will need IP address this to connect.


contianer IP .jpg


So we now have the 3 pieces of information to connect to this SQL instance ,we have the user name and password (from the docker run command): 

IP address of container running SQL
User name for SQL  SA
Password for SQL barkmeow88!!!!!


Now we install SQL management studio from Microsoft site and launch it.  Open the SQL Management studio and select "file" and " connect object explorer" and you will be presented with the screen below .


 select SQL auth.jpg


Enter in the vales from our table for the Container IP , login and password for SQL. Make sure you set the authentication  to "SQL Server Authentication".  Click "connect" 

 connected .jpg 


You can now connect to the SQL running in a container and are free to add a test database just as you would if MSSQL were installed on a standalone server.

Brian Keyes

A former Vizuri systems engineer with more than twenty years of experience, Brian Keyes provided authority on subjects including VMware, storage, networking, and security. Interested in this post? Connect with our team of experts by