Dockerize Microsoft SQL Server on MacOS

Install, Load Data, and Run Queries

Etimbuk U
2 min readFeb 11, 2019

In the last few weeks, I have had the opportunity of working on a new project which needed me to be familiar with MSSql Server — using T/SQL and the usual SQL. So, as you might have guessed, the first step was to install MSsql server on my MacOS and interesting enough this is currently not available for on Mac.

Alright 🤔, what do I do? Yep! you guessed right. Googled it, and I will like to share what I learned Googling with you here😃.

Installation

Prerequisites

  • Docker Installation. See Install Docker for updated steps.
  • Minimum of 2GB of disk space
  • Minimum of 2GB of RAM

Cool, now you have met the prerequisites lets now pull the Microsoft SQL server image from Docker registry.

Step 1: Launch a Terminal on your MacOS.

Step 2: Pull Microsoft SQL Server image using below command

Step 3: Run the pull-ed docker image using

The following table provides a description of the arguments in the above docker run command.

At this point, we now have MS-SQL Server up and running, so let's upload data and run some queries.

Load Data

MS-SQL is a Database Management System, so we will need to create a database, upload data and run a few queries.

Data which we will be uploading is an extract of the Consumer Complaint dataset. This is available from here.

But before we do this, let's connect to our container and download this data to a directory.

The below table describes these commands

I am sure a few curious minds are asking

Can pulling the MS-SQL Server image, setting environment variables and downloading test data be done with docker? The answer is a resounding YES.

This is demonstrated in the Dockerfile below

Now we have our demo data lets upload using the following steps

  • Connect to MS-SQL container. To achieve this I recommend downloading and using Azure Data Studio. This is a stripped down version of SSMS (SQL Server Management Studio).
Connectin to MS-SQL Server using Azure Data Studio
  • Run below command

Run Queries

Now we have a dataset, let's run a few queries.

--

--

Etimbuk U
Etimbuk U

Written by Etimbuk U

Java | Flutter | Android | Some JavaScript | API Design

No responses yet