How to Run SQL Server 2017 & 2019 Simultaneously on a Mac

As I write this, there are two releases of SQL Server that can be run on a Mac: SQL Server 2017 and SQL Server 2019 Preview. This article explains how to run both of these on a Mac so that they run simultaneously. No need to uninstall one before you install the other.

The key is to use a different TCP port number for each instance (the TCP port that the containers are mapped to on the host machine). If you don’t do this, you’ll get an error. SQL Server uses port 1433 by default, which is fine to use for one of your instances, but not both. Therefore you’ll need to change this for at least one of your installations.

Download SQL Server

These instructions assume that you have Docker installed and running on your Mac. You need Docker in order to run SQL Server on your Mac (unless you choose to install it on Windows via a VM, but that’s not what we’re doing here). If you don’t have Docker, jump to the “Detailed Instructions” section at the bottom of this article.

To download the latest SQL Server 2017 image, run the following command:

sudo docker pull mcr.microsoft.com/mssql/server:2017-latest

To download SQL Server 2019 Preview, run the following command:

sudo docker pull mcr.microsoft.com/mssql/server:2019-CTP3.2-ubuntu

Note that this is the latest release at the time of writing. For the latest image, check the official SQL Server repository on the Docker website.

Run the Containers

Now that both container images have been downloaded, run the following commands:

sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=BigStrong#Pwd2017" -p 1401:1433 --name sql1 -d mcr.microsoft.com/mssql/server:2017-latest
sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=BigStrong#Pwd2019" -p 1402:1433 --name sql2 -d mcr.microsoft.com/mssql/server:2019-CTP3.2-ubuntu

Change the name and password to your own. Also, if you’re using a different release, change the path accordingly.

In this case, I create a SQL Server 2017 container and a SQL Server 2019 container, and map them to TCP ports 1401 and 1402 on the host machine. In both instances, SQL Server is listening on port 1433 in the container.

That’s all. You should now have SQL Server 2017 and SQL Server 2019 running simultaneously on your Mac!

Connecting to your SQL Server Instances

You’ll need to append the port number when connecting to each instance. Here’s an example of using the mssql-cli command line tool to connect to the SQL Server 2017 instance:

mssql-cli -S Localhost,1401 -U sa -P BigStrong#Pwd2017

Some GUI tools might have a separate field for the port. Otherwise you should be able to use the same Localhost,1401 format.

Detailed Instructions

The above instructions assume that you have Docker on your Mac, and that you already have some knowledge of installing and connecting to SQL Server on a Mac. If you don’t, the following two articles should help.

  • Install SQL Server (2017) on a Mac

    This article shows how to install SQL Server using the default port setting (1433:1433). Includes installing Docker and connecting to SQL Server from a command line interface, as well as links to GUI tools.

  • Install SQL Server 2019 on a Mac

  • This article shows how to install SQL Server using a different port (1400:1433). Actually, it starts off on the default port but then shows you the error you’d get if you try to run two instances on the same port. It then shows how to change that port (just like in the above example). This article also includes installing Docker and connecting to SQL Server from a command line interface, as well as links to GUI tools.