Install MSSQL Server Through Docker File

Install MSSQL Server through Docker file

In this blog, we will show you how to install MSSQL server through docker file in windows 2016.

REQUIREMENTS

  • Windows Container Host with docker installed
  • SQL Installation Files
  • Windows 2016 Server Core container image.

SQL IMAGE PREPARATION

  • Mount the windows ISO image and copy the SXS folder to c:\mssql\source folder.
Install MSSQL Server through Docker file

Note : The detailed steps about this preparation is explained in this blog : https://blog.assistanz.com/install-mssql-server-2016-in-windows-container/

CREATING DOCKER FILE

  • Create a new file named dockerfile under c:\mssql folder.

Note: The dockerfile should have any extension

Install MSSQL Server through Docker file
  • Open the dockerfile in notepad and paste the below code.

# Install MSSQL

# Specifying Container Image
FROM microsoft/windowsservercore

#Copy MSSQL SETUP FILES INTO THE CONTAINER
ADD ./source c:/source

# Install DOTNET AND MSSQL 2016

RUN powershell.exe -command \

install-windowsfeature -name NET-Framework-Features -IncludeAllSubFeature -Source c:/source/sxs; \
c:/source/setup.exe /configurationfile=c:/source/configurationfile.ini; \
sc.exe config MSSQLSERVER obj=LocalSystem; \
remove-item c:/source -Recurse

  • Save the file and close it.

CREATING AN IMAGE USING DOCKERFILE

  • Open PowerShell window and type the below command to build the MSSQL container.

docker build –t MSSQL2016 c:\MSSQL

docker build – It’s a sub-command to build the images in docker.

-t – To tag the image name

c:\MSSQL – The path where dockerfile is available to build the container image.

Install MSSQL Server through Docker file
  • It will take several minutes to complete the build.
Install MSSQL Server through Docker file
Install MSSQL Server through Docker file
  • Once it’s completed, type docker images to list the available images in the container host.
Install MSSQL Server through Docker file
  • Now our new image MSSQL container image is ready to use.
VIDEO 

Thanks for reading this blog. We hope it was useful for you to learn how to build MSSQL container image using docker file.

Loges