Navigate back to the homepage

Running Microsoft SQL Server.. on a Mac!

Mark Brown
October 6th, 2020 · 1 min read

👋 Introduction

A few years ago I switched my main work machine from Windows to Mac – despite the reliance I have on SQL Server to run our application (Well, there’s also the dev-only H2 database, but even then I knew that wouldn’t fly due to some of the ‘subtle’ differences).


At the time I had no idea what containerisation was – so i’d thought my only option was to run my database in a Windows VM or use Wine to run SQL Server natively. Thankfully I was then introduced to docker – it allowed me to run my database on the Mac OS side (well, technically within a Linux container), rather than faffing around with a Windows VM, now I can gladly say I only need a Windows VM for one task, and that’s because i’m yet to find a replacement a powerful as SSMS for comparing query plans.

🐳 Installing Docker

Installation of docker is pretty straightforward, just follow the instructions on the docker site. Once complete, the Docker ‘whale’ icon should be visible in the Mac OS menu bar.


🏃‍♂️ Pull & Run the SQL Server Docker image

In a terminal window of your choice (I recommend iTerm2) – run the following;

Pull the container image from Docker Hub

1sudo docker pull

Run the image

1sudo docker run \
2 -e "ACCEPT_EULA=Y" \
3 -e "SA_PASSWORD=<YourStrong@Passw0rd>" \
4 -p 1433:1433 \
5 --name sql1 \
6 -d
-e “ACCEPT_EULA=Y”Set ACCEPT_EULA to confirm you accept the end user licensing agreement, this is required to start the image.
-e “SA_PASSWORD=<YourStrong@Passw0rd>”Specify your own strong password, again this is required to start the image.
-p 1433:1433Map a port number on the host environment (your machine) to with a TCP port on the container (second number)
-name sql1A name for the container. If not specified, a random one will be generated.
-volume /Users/mark/DockerShare:/HostShare/Map a shared folder from the Host OS to the docker container (Very useful for transferring database backups!)

Connect to Docker SQL Server with a SQL Editor

So, you may have guessed by now – but not only will SQL Server not work on Mac OS, but neither will SQL Server Management Studio! But fear not, Microsoft still has our backs – I have been using Azure Data Studio to connect to and manage my SQL Server container, and have found it can do (almost) everything I need. To connect, simply input the login credentials specified when running the container.


Or, the lazy way

I have written a quick Python script to install my DB, alongside some useful Stored Procedures I use for monitoring (you should too - but that’s a story for another day!) - and this can be found on my GitHub

💅 Summary

As you can see – it’s very simple to get an instance of SQL Server running in Docker. Within a few short minutes, you can have the Server up and running – and likewise – replace an existing SQL Server image (if you’re anything like me, replacing the image will be pretty common if you bloat it with unused database backups!).

More articles from Mark Brown

TIL - Comparing Strings with trailing spaces using TSQL

I set off down this path of enlightenment as I investigated a customer issue that “could never happen”.

December 2nd, 2021 · 1 min read

Automate away your N+1 problems with Hibernate Statistics

If you are using an ORM in your projects, The N+1 query problem is definitely one of your issues. If you don't know that yet - well, may the Lord have mercy on your soul.

November 29th, 2021 · 1 min read
© 2020–2021 Mark Brown
Link to $ to $ to $ to $