MS SQL Server on MacOS with Docker and VS Code
Tags: net, docker, macos, mssqlserver
Published: 2020-04-15 13:23:17

---
title: MS SQL Server on MacOS with Docker and VS Code
published: true
date: 2020-04-13 21:43:03 UTC
tags: .NET,Docker,MacOS,MS SQL Server
canonical_url: http://blog.ijasoneverett.com/2020/04/ms-sql-server-on-macos-with-docker-and-vs-code/
---

Now that Docker has made every developers life easier, I’m going to walk you through a few quick steps to get Microsoft SQL Server up and running on MacOS. The first thing you need to do is install Docker on your Mac.

**Install Docker**  
I chose to install [Docker Desktop](https://www.docker.com/products/docker-desktop) so that’ll be what I’ll be using for this tutorial. You can choose to install Docker Toolbox if you choose. Use the following link to determine which best fits your needs: [https://docs.docker.com/docker-for-mac/docker-toolbox/](https://docs.docker.com/docker-for-mac/docker-toolbox/)

**Docker Settings**  
Once Docker Desktop is installed, launch it and open the settings by clicking the docker icon and selecting Preferences.  
[![](https://i2.wp.com/blog.ijasoneverett.com/wp-content/uploads/2020/04/Screen-Shot-2020-04-13-at-3.23.21-PM.png?resize=356%2C367)](https://i2.wp.com/blog.ijasoneverett.com/wp-content/uploads/2020/04/Screen-Shot-2020-04-13-at-3.23.21-PM.png)

This will launch your Docker Dashboard. Once opened, clicked the Settings gear at the top right and click on Resources >> Advanced. SQL Server needs at least 3.2 GBs of memory so increase the Memory to 4 GBs and click Apply & Restart.  
[![](https://i0.wp.com/blog.ijasoneverett.com/wp-content/uploads/2020/04/Screen-Shot-2020-04-13-at-3.23.56-PM.png?resize=600%2C356)](https://i0.wp.com/blog.ijasoneverett.com/wp-content/uploads/2020/04/Screen-Shot-2020-04-13-at-3.23.56-PM.png)

**Download the SQL Server Image**  
To download the SQL Server image, open Terminal and type the following:  
`docker pull mcr.microsoft.com/mssql/server:2019-latest`  
This will download the latest SQL Server 2019 image to your mac.


**Launch the SQL Server Image**  
From Terminal, run the following command:  
`docker run --name ms_sql_server -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=5uper5trongPW!' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest`  
Don’t forget to change the password to your own secure password. This command sets the name of the docker container to ms\_sql\_server. The user is defaulted to sa. For more configuration settings, go the [MS SQL Server container hub](https://hub.docker.com/_/microsoft-mssql-server). Once you launch the image it’ll be available in Docker Dashboard. From here you can stop the image, restart it, delete, etc.  
[![](https://i0.wp.com/blog.ijasoneverett.com/wp-content/uploads/2020/04/Screen-Shot-2020-04-13-at-3.33.27-PM.png?resize=600%2C349)](https://i0.wp.com/blog.ijasoneverett.com/wp-content/uploads/2020/04/Screen-Shot-2020-04-13-at-3.33.27-PM.png)

**Visual Studio Code**  
There are several MS SQL Server GUIs available for MacOS but I prefer to use VS Code since its my development tool of choice. To install the MS SQL extension on VS Code, click the extensions icon and type: _mssql_. From the search results, select _SQL Server (mssql)_ and click Install. After the installation completes, select Reload to enable the extension. Once enabled, you’ll have a SQL Server icon on the left. Click on it and select Add Connection.  
[![](https://i0.wp.com/blog.ijasoneverett.com/wp-content/uploads/2020/04/Screen-Shot-2020-04-13-at-3.44.55-PM.png?resize=358%2C516)](https://i0.wp.com/blog.ijasoneverett.com/wp-content/uploads/2020/04/Screen-Shot-2020-04-13-at-3.44.55-PM.png)

Follow the prompts, using localhost as hostname, sa as user and your password you set up when launching the SQL Server image. You should also give your connection a name to be able to identify it later. For this tutorial I named my connection TestSQL.  
[![](https://i2.wp.com/blog.ijasoneverett.com/wp-content/uploads/2020/04/Screen-Shot-2020-04-13-at-3.49.22-PM.png?resize=600%2C378)](https://i2.wp.com/blog.ijasoneverett.com/wp-content/uploads/2020/04/Screen-Shot-2020-04-13-at-3.49.22-PM.png)

That’s it! You now are free to create your database, tables, etc.

**Note:**  
If you stop and remove your container, you’ll lose all your SQL Server data. To avoid this you can create a backup of your database or you can [persist your data in volume containers](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-configure-docker?view=sql-server-ver15#use-data-volume-containers).