[70] SQL Server 2012 / 2014 / 2016 in Docker

We have the latest versions of Microsoft SQL Server in Docker Hub provided officially by Microsoft itself. We can get the same at this URL: https://hub.docker.com/_/microsoft-mssql-server

But if we need to run older versions like Microsoft SQL Server 2012 / 2014 / 2016, we have to mostly use the on-host installations.

An alternative approach is to build Docker Images ourselves using the MSSQL installer we get from Microsoft. I have done the same for each of MSSQL 2012, 2014 & 2016. Though the images I built might not be the most robust and production-ready, they can be used to quickly set up a test environment.

I have written below the commands to run each version.

Common Error

If you see the error I have mentioned below at any point, add a tag called --isolation=hyperv in your docker run command

The container operating system does not
match the host operating system.

Your docker run command should look like “docker run --isolation=hyperv --name ...“. Check the commands below for each SQL Server version.

Container Mode

You should be in the “Windows Container Mode” to run any of the Docker Images below. This is due to the fact that all of the Images below were built using a Windows Docker Image. Even Microsoft didn’t release a Linux distributable for Microsoft SQL Server versions 2012, 2014 and 2016.

Please follow the below steps if you are on Linux Container Mode

  • Navigate to path C:\Program Files\Docker\Docker
  • Run the following command: ./DockerCli.exe -SwitchDaemon

If you don’t understand Container modes, you may do a quick Google search to learn more about the same.

Microsoft SQL Server 2012

Build instructions: [17] Microsoft SQL Server 2012 on Docker

Run command:

docker run -itd --name my-mssql-2012-server -p 1433:1433 -d anushibin007/mssqldb:2012-express

Credentials: sa / password

Microsoft SQL Server 2014

Build instructions: [68] Microsoft SQL Server 2014 on Docker

Run command:

docker run -itd --name my-mssql-2014-server -p 1433:1433 -d anushibin007/mssqldb:2014-express

Credentials: sa / Passw0rd

Microsoft SQL Server 2016

Build instructions: Similar to [17] Microsoft SQL Server 2012 on Docker

Run command:

docker run -itd --name my-mssql-2016-server -p 1433:1433 -d anushibin007/mssqldb:2016-express

Credentials: sa / password

Leave a comment