SQL Server 2017 in a Container – Part 2

In Part 1 I showed how to get Docker for Windows installed on a Windows 10 machine.

In this blog we will search and pull down the latest SQL Server 2017 image.

Docker Hub

Docker public images are stored in a docker registry called Docker Hub. Images are the building blocks of containers. This is where Microsoft publishes the MSSQL images.

The images are created using a dockerfile. You can view the source at Microsoft’s Github repository.

Searching for MSSQL Images

From a command prompt run docker search mssql | find “Microsoft”

Anyone can create a docker hub image however; what we are interested in are the Microsoft/ prefixed images. We have two windows and two Linux images. The mssql-tools image are the command line tools for Linux.

I am interested in mssql-server-windows-developer image. We can view this image details online here.

If you click on the Tags tab it shows you when the latest version was built. By default when we pull an image if we do NOT specify the tag, it will look for latest tag. Here you can see there are in fact a 2017-CU3 and 1709 tag built after the latest.

Pulling Down the Image

Now we know what image we want lets pull it down. I am going to pull the very latest which is 1709. From a command prompt run:

docker pull microsoft/mssql-server-windows-developer:1709

An image is made up layers. Down at the lowest layer you typically have the operating system, then as customizations are made from a dockerfile for example, new layers are added. Docker uses a union file system to combine these layers into a single image. All these layers are read-only. Ill mention the write-layer when required.

When the pull is running it will download each layer. Some are really small and some are GBs.

Once fully complete it should look like this.

List the images on your system.

docker image ls

The first entry shows our image pulled down with a tag of 1709. The size on the right shows 10.8GB so pretty big.

We can view the history of an image which shows how the layers were constructed.

docker history 3cfcf17ef2dd

The two layers at the bottom are the Windows Server Core layer which is why it’s around 6GB. The two other GB sized layers are when the SQL Server software was copied and SQL setup run to create the default instance. These all come from the dockerfile.

Note: There was a change in a recent version of docker that stopped showing the parent layer ids. This is why you are seeing for all layers except the latest one. Just ignore it. I am sure the command output will change in the future since it could imply there is an issue.

In the next blog we will use this image to create a container.