SQL Server 2017 in a Container – Part 7

In the last blog I explained how we can use volumes to persist our database data.

In this blog I will show you how to create your own image which includes a SQL Server cumulative update.

Download the Latest SQL 2017 Cumulative Update

The current image we have been using is SQL 2017 RTM-CU3. At the time of writing CU4 has been released. Let’s take the current image by Microsoft, add CU4 and then create our own image which we can use for creating our containers.

Navigate to https://www.microsoft.com/en-us/download/details.aspx?id=56128 and download the CU.

Copy the CU to our volume folder T:\DockerVolumeLocation\Demo because we need to be able to access the file from within the container. Note: docker cp does not work for windows containers at the time of writing.

docker create –name Demo -v T:\DockerVolumeLocation\Demo:C:\VolumeData –network Hyper-V-External-Network –hostname demohost -p 1433:1433 –cpu-count 2 –memory 4g -e sa_password=Password1#### -e ACCEPT_EULA=Y microsoft/mssql-server-windows-developer:1709

docker start Demo

Execute Cumulative Update

Note: Containers do not allow UI’s to run so we must execute the install using command line parameters.

First let’s check the SQL version we currently have.

Check the update exists shows up in C:\volumedata


It will return back to the prompt immediately and setup will run in the background. Using powershell we can view the setup process.

This blog is not a SQL Server tutorial so I assume the reader knows how to install CU’s. Check the log files in C:\Program Files\Microsoft SQL Server\140\Setup Bootstrap\log when it completes to make sure it has worked ok.

Once it completes check the SQL version to confirm CU4 has been applied.

Generating a New Image

Here is a picture of our current container. Up at the top layer is where we have written our new CU into. What we now need to do is commit those changes and create a new image to build future containers.

docker stop Demo

docker commit Demo sqlserver2017cu4

This has created a new image which has now turned our writable layer into a read-only layer. Note: it does not include what is in the volume folder T:\DockerVolumeLocation\Demo

docker image ls

We can see the new image with a latest tag because I did not specify one.

Create a New Container using our New Image

Create a container called Demo2. I have also created a Demo2 folder in our volumes folder for isolation.

docker create –name Demo2 -v T:\DockerVolumeLocation\Demo2:C:\VolumeData –network Hyper-V-External-Network –hostname demohost -p 1433:1433 –cpu-count 2 –memory 4g -e sa_password=Password1#### -e ACCEPT_EULA=Y sqlserver2017cu4

docker start Demo2

Let’s check the SQL version.

We now have our own image. You can imagine how you could create golden images by laying images on top of each other.

This blog is the last one in the series. I hope it was useful.