In this final part of my series on SQL Server & Containers I’ll detail an option to run earlier versions of SQL Server in containers.
This post follows on from Part Three in which we uploaded a custom image to the docker repository.
The three previous posts have all been detailing how to run SQL Server 2016/vNext in containers on Windows Server 2016, but I’m guessing that a lot of people out there are using earlier versions of SQL Server in production. Containers can be a really handy tool for development and QA but there’s no point in running SQL in containers that’s a higher version that your production environment.
Say you’re running SQL Server 2012 in production and you want to be able to run containers with instances of SQL Server 2012. What options have you got? Well, one option is in the form of a custom port of the open source software that Docker have released to the community built by a company called WinDocks. WinDocks software allows earlier versions for SQL Server to run in containers on earlier versions of Windows Server.
They have a free community edition available here so that you can see the software in action.
Let’s go through creating containers with SQL Server 2012 instances on Windows Server 2012 R2.
So the first thing to do is get a new server with Windows Server 2012 R2 installed. Then once that’s up and running, you need to install SQL Server…
The WinDocks software is different from the previous docker software that we’ve worked with in that it needs an instance of SQL installed on the host in order to use it’s binaries to create SQL within the containers. The instance won’t need to be running, it just needs to be installed.
So, the following SQL server features need to be installed on the server:-
EDIT: The guys from WinDocks have informed me that the configuration of SQL is now handled by the WinDocks installer, so all you have to do is install SQL and then run the package. I’m leaving the below parts in this post so you know what the package is doing but it’s now all handled automatically
Once SQL Server is installed set all the services to manual, apart from the SQL Browser service which needs to be on automatic startup. The following also needs to be enabled:-
- Mixed mode authentication
- Remote connections
- TCP ports
- Named pipes
Then once SQL is installed and configured, run the WinDocks package that you downloaded from the link I specified earlier (it’ll take about 10 mins):-
Reboot the server and once it’s back up open an administrative command prompt window (I’m also going to turn it into a PoSH window).
Navigate to C:\windocks\bin and run:-
docker -H tcp://0.0.0.0:2375 -d
This will start up the docker daemon, allowing you to send requests to it to create containers.
Once the daemon is up and running, open another command prompt and run: –
The WinDocks software comes with three images, the one we’re interested in is the mssql-2012. So let’s build a new container running an instance of SQL Server 2012!
First step is to run:-
docker create mssql-2012
What we’ve done here is create a new container from the mssql-2012 image that came with the WinDocks software (built from the instance of SQL that we installed).
Next thing is to start the container, so my container’s reference is ab3, so I’ll run:-
docker start ab3
Once you see something similar to below, your container is up and running:-
The container behaves like a named instance of SQL Server. To connect you need to enter the SERVERNAME,PORT. So for me to connect locally, using the sa credentials detailed when I created the container:-
And boom! I’m in:-
So that’s how to get earlier versions of SQL Server running in containers on earlier versions of Windows!
Thanks for reading!