[17] Microsoft SQL Server 2012 on Docker

Update: Check out [68] Microsoft SQL Server 2014 on Docker too!

Building an image to run Microsoft SQL Server 2012 was fun. Though there were many hurdles along the way, the steps are pretty simple once we come to know about the pre-requisites. If you were not aware, the official Docker Images of Microsoft SQL Server are available only for the versions 2017 and 2019. So if we want any version other than those, we have to build it ourselves.

The exact version of Microsoft SQL Server 2012 that I am Dockerizing is: Microsoft SQL Server 2012 – 11.0.5058.0 (X64) May 14 2014 18:34:29 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.3 (Build 14393: ) (Hypervisor)

The ultimate Dockerfile (this is what you came for):

FROM mcr.microsoft.com/dotnet/framework/runtime:3.5-windowsservercore-ltsc2016

COPY sql_server_2012 C:/sql_server_2012

RUN C:/sql_server_2012/setup.exe /ACTION=install /Q /INSTANCENAME="MSSQLSERVER" /SQLSVCACCOUNT="NT Authority\System" /AGTSVCACCOUNT="NT AUTHORITY\Network Service" /IACCEPTSQLSERVERLICENSETERMS=1 /FEATURES=SQLENGINE /SQLSYSADMINACCOUNTS="BUILTIN\Administrators" /SECURITYMODE=SQL /SAPWD="Passw0rd" /TCPENABLED=1 /SQLSVCSTARTUPTYPE="Automatic" || exit 0

EXPOSE 1433

Yup. That’s it. 4 lines. And it took 4 days to come to these 4 lines. If you are wondering what was there in that sql_server_2012 folder, it is the extracted folder that you get when you run the Microsoft SQL Server installer that you download from the official Microsoft website. Here’s a quick look of what will be there inside that folder:

Microsoft SQL Server 2012 Setup folder content
Microsoft SQL Server 2012 Setup folder content

You’re still here? Then most probably you faced some issues with the build command. So I am pasting the command that I used to build it:

docker build --isolation=hyperv --rm --memory 8G -t mssqldb:2012-express .

I used the “–isolation=hyperv” option in between because I built this image on a Windows Server 2019 host. The base image is a Windows Server 2016 Docker Image. So apparently I needed that. And don’t forget the “–memory 8G” option too. Otherwise, the installation may fail during the Docker build process. The End.

If you are still here, please follow for more 😊

3 thoughts on “[17] Microsoft SQL Server 2012 on Docker

Leave a comment