Install SQL Server Express on Windows Server 2016 using docker containers

In this article, we will install the SQL Server Express edition on Windows Server 2016 using a SQL Server Docker


The virtual machine uses the virtualization technique to virtualize the physical hardware. Suppose we install the
Oracle VirtualBox in a physical server. We can configure multiple virtual machines with their operating system,
application, software, databases system, networking components. As shown below, we have created two virtual
machines. These virtual machines are completely separated from each other. In my earlier articles on SQL Server Always On Availability Group, we configured the AG between the different virtual machines.

Virtual Machine

In the below image, we see a docker container. In a virtual machine, we install the operating system, but the
containers virtualize the host operating system. It also reduces administrative efforts to manage multiple operating

SQL Server docker container

We can use the containers on both On-premises and cloud platforms for multiple applications and different languages.

Containers in the cloud or on-premises

Image reference: Microsoft docs

You can refer to this article to understand the difference between Virtual machines and Containers.

We can install SQL Server on both virtual machines and containers. We require to install separate SQL Server on each
virtual machine, its dependencies such as .Net frameworks. A container makes the task easy for us to quickly create
multiple instances of SQL Servers and query databases.

In this article, we will configure the SQL Server container on the Windows Server 2016.

Installing Docker services on Windows server 2016

Usually, docker and container terms are for the Linux operating system. Most of the time SQL database professionals
do not familiarize themselves with these technologies due to different operating systems. Windows Server 2016 has
in-built support for containers. To use the containers, we use the following steps in Windows Server 2016 server.

  • Step 1: Enable Container feature
  • Step 2: Install the Docker-Microsoft PackageManagement provider (DockerMsftProvider)
  • Step 3: Install the docker package

Let’s start with the docker configuration for the Windows Server 2016.

Step 1: Enable Container feature

Take RDP of the Windows Server 2016 server and navigate to Server Manager-> Add roles and features.

In this wizard, select the installation type – Role-based or feature-based installation.

Enable Container feature

Put a tick on the Containers feature, as shown below.

Containers feature

To enable the Container feature, we require to restart the virtual machine. You can do it manually or put a tick on
the Restart the destination server automatically if required.

Restart the destination server automatically if required

It automatically restarts the server and configures the Container in Windows Server 2016.

restarts the server

Finished container feature installation

Alternatively, you can use the below PowerShell command to install the Container feature.

Step 2: Install the Docker-Microsoft PackageManagement provider (DockerMsftProvider)

In the second step, launch the administrative Windows PowerShell to install the Docker-Microsoft Management provider for Windows server 2016.

Specify Yes to install the NuGet provider.

Install the Docker-Microsoft PackageManagement provider

Step 3: Install the docker package

In this step, we install the PackageManagement PowerShell module in the Windows PowerShell.

Install the docker package

Now, open the services and start the Docker Engine service either manually or using the below PowerShell command.

Docker Engine service

Docker Engine service using PowerShell

The Docker Engine service is in the running status.

Docker Engine service status

Verifying Docker Installation

We can use the docker command to gets its argument, commands and their descriptions.

Verifying Docker Installation

We use the docker version command to check the docker engine and client version.

docker version command

Install SQL Server Express edition using SQL Server docker for Windows Server 2016

The docker service must be running to install SQL Server Express. In a traditional environment, we use the
installation media and go through the various installation steps. Similarly, for a SQL container, we need an image.
We can download the image from the docker hub repository. It is an open-source medium to upload and download the

To search for the SQL Server docker images, use the following docker search command.

Install SQL Server Express edition

In this article, we want to install the SQL Server Express edition. To download the repository, we need an active
internet connection. It uses the docker pull command for this purpose.

It starts downloading the SQL Server docker container images for SQL Server Express edition from the specified repository.

Container images

It extracts the SQL Server image after the download completes.

extracts the SQL Server image

Download completes

To check the existing downloaded docker images, we can use the docker images command. As shown below, we have
mssql-server-windows-express in our local repository.

existing downloaded docker images

Now, comes the best part for a SQL Server docker container. Suppose you have to need to prepare multiple SQL
database environment for your code testing. Let’s name the environment as development, unit test. In the VM, we need
to go through the installation wizard and configure the SQL Server. It can be a complicated task for you, especially
if you need it for testing purposes only. With the different environment, you might also complain sometimes- the
code was working fine on the dev server.

SQL Server docker container solves the issue. To install SQL Server using a container, run the following command.

Here, we have used the following arguments for the docker run command:

  • Name: It is a name for your container. It is good to specify a customized name to identify the
    container instead of a randomly generated name
  • d: SQL Server runs as a service. Therefore, we need to use this option
  • p: Use this argument to map the TCP port on the host environment and the container. We specify
    the port in the format such as -p 1433:1433. Here, the first 1433 port is for the container and the second TCP
    is for the host port
  • sa_password: Specify the password for the system admin account in SQL Server
  • ACCPET_EULA: This argument is to accept the end-user license agreements

Run the docker run command specified above and it returns the container ID as shown below:

docker run command

You can run the docker ps -a command to check the docker containers in Windows Server 2016. As
shown here, we have a SQL Server Express edition. It quickly configures SQL Server for you.

docker command

To connect to the SQL Server docker instance, we need to IP address of the container. We can use the docker inspect
command for this requirement.

It returns the IP address, as shown below. For my [sqlshackdemo] container, the IP address is

IP address of the container

Install SQL Server Management Studio and access the SQL Server container using the IP address, SA authentication.

As shown below, it installed the Microsoft SQL Server Express edition for my Windows container.

Microsoft SQL Server express edition

Now, suppose you need to install another SQL instance. It is again a fraction of second work. Specify the argument
value in the docker run command, and your SQL instance is ready.

We get an error this time because of the port number. It is not able to create the endpoint on port 1433 because we already used it for [sqlshackdemo] container.

port number

To use the existing docker container name, we need to remove it.

>docker run sqlshackdemo_2nd

Change the SQL Server docker container port and run the docker run command, as shown below.

Change container port

Check the IP address and connect to the SQL Server instance in SSMS.

Checking IP address.

Connect second container

You cannot stop the SQL Server in Docker using the SQL Server Configuration Manager. You can use the docker stop
command for this purpose.

stop the SQL Server Docker


In this article, we installed the SQL Server Express edition on Windows Server 2016 using the SQL Server docker
container. Docker container is an excellent way to quickly deploy multiple SQL instances and use them for the work.
I would recommend you explore it.

Rajendra Gupta
Latest posts by Rajendra Gupta (see all)

Author: admin

Leave a Reply

Your email address will not be published.