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