Docker on Windows Server: Dockerize SQL

Posted by Brian Keyes

Apr 25, 2017 9:40:00 AM Docker, Docker Containers, windows containers


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".

deploying.jpg

 

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 172.17.254.209
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.

Posted by Brian Keyes

Brian has over 20 years of experience as a Systems Engineer with a strong background in VMware, storage, networking and security. Brian has worked for variety of US Govt. entities over the years;DOD,NGA,NNSA and others. Currently focused on Docker technologies

Find me on:

An Open View

Vizuri Blog

Subscribing to our blog is a great way to stay up to date with the latest information from Vizuri, as well as our strategic partners. We focus on providing a range of content that is practically useful and relevant from both a technical and business perspective.

We promise to respect your privacy.

×