Install MSSQL Server through Docker file
In this blog, we will show you how to install MSSQL server through docker file in windows 2016.
- Windows Container Host with docker installed
- SQL Installation Files
- Windows 2016 Server Core container image.
SQL IMAGE PREPARATION
- Download the SQL ISO from Microsoft site (https://www.microsoft.com/en-in/evalcenter/evaluate-sql-server-2016) and extract to a folder named source under MSSQL folder.
- Mount the windows ISO image and copy the SXS folder to c:\mssql\source folder.
- Download the unattended file (Configurationfile.ini) from our Github (https://github.com/assistanz247/MSSQL2016/blob/master/ConfigurationFile.ini) and paste into c:\mssql\source folder.
“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
- Open the dockerfile in notepad and paste the below code.
# Install MSSQL
# Specifying Container Image
#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.
- Also, we have uploaded the dockerfile in the Github online repository. The URL is https://github.com/assistanz247/MSSQL2016/blob/master/dockerfile
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.
- It will take several minutes to complete the build.
- Once it’s completed, type docker images to list the available images in the container host.
- Now our new image MSSQL container image is ready to use.
Thanks for reading this blog. We hope it was useful for you to learn how to build MSSQL container image using docker file.