What is Docker? Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications, whether on laptops, data centers, VMs, or in the cloud. Docker allows applications to be isolated into containers with instructions for exactly what they need to survive that can be easily ported from machine to machine. Though Virtual machines also allow the exact same thing, and numerous other tools already exist to make rebuilding these configurations portable and reproducible, Docker has a more simplified structure compared to both of these, the real area where it causes disruption is resource efficiency.

I strongly recommend reading the following resources:

Now let’s get started on Running SQL Server on Linux in Docker on Windows

Install and configure Docker

If you don’t already have Docker installed, you will need to download and install Docker for Windows (Requires Microsoft Windows 10 Pro or Enterprise 64-bit). New to Docker here is the best place to start -> Get started with Docker for Windows.

An important requirement for Docker to run SQL Server on Linux is to configure it with a minimum of 4 GB of RAM.
To configure:

    -Right-click on the Docker icon from the task bar.
    -Click Settings under that menu.
    -Click on the Advanced Tab.
    -Move the memory indicator to 4GB or more.
    -Click the Apply button.

Now that Docker is installed and configured let do the next steps…

Pull and Run the Docker image

The following link -> Run the SQL Server vNext Docker image on Linux, Mac, or Windows explains how to pull and run the mssql-server Docker image. This image consists of SQL Server running on Linux and can be used with the Docker Engine 1.8+ on Linux or on Docker for Mac/Windows.

Open a Windows PowerShell session and type the following to pull the image:

Once completed it should state that it successfully downloaded the image…

Important: Before we run the image I want to point out that in my local environment (Surface Book) I already had a copy of SQL Server 2016 installed, So my docker run command needed to be modified to map to a different port than the default 1433. I opted for 1500, hence the -p 1500:1433 instead of -p 1433:1433.

I also want to inform you about the following option: –name sqllinux01 I personally think it is best practice to name your containers instead of leaving it to docker to create those cosmic names 😉

So below is my docker run command which maps my host port (1500) to the container port (1433), names my containter sqllinux01 and persists the data generated from the docker image to my local disk (D:\docker-data-volume\sqllinux01) – You can use the following command, but please make sure to replace PUT_YOUR_PWD_HERE with your own password.

Our container is now active and running. To get a list of all containers, running or not issue the following command:

You should see your active sqllinux01 container…

Connect to SQL Server on Linux

Now we can start using SQL Server on Linux in Docker. Starting with SQL Server vNext CTP 1.4, the SQL Server command-line tools are included in the Docker image. In order to connect from Windows you need to have the Microsoft Command Line Utilities for SQL Server installed. To get the latest version -> https://www.microsoft.com/en-us/download/details.aspx?id=53591

Run the sqlcmd with parameters for your SQL Server name (-S), the user name (-U), and the password (-P) and issue the following SQL statement: select @@version

Voilà we have connected to SQL Server on Linux running in a Docker image container…

If you would like to attach to an already running container and issue some bash linux commands inside the container – In this examples /bin/bash is used as the command:

docker exec -it CONTAINER_ID /bin/bash

Simply replace CONTAINER_ID with your container identifier in this case sqllinux01 is my container name

Some other resources – Docker Cheat Sheets:

And yes always keep up to date with the SQL Server on Linux Documentation


Tagged with →