How I Used Docker to Spin Up SQL Server on My Mac in 3 Easy Steps
Tags: sqlserver, docker, dotnet, beginners
Published: 2024-01-18 04:47:29

Hi friends!

So, I recently kicked off a pretty cool [90-Day MVP project](https://blkgrlcto.com/2024/01/13/im-building-nextconf-pro-in-public-using-net-ama/) and guess what? I bumped into a bit of a snag – I needed to get SQL Server up and running on my Mac. Now, if you’ve ever tried this, you know it’s not the most straightforward task. SQL Server and Macs don’t usually play nice together, right? But don’t worry, I’ve got you covered. In this blog post, I’m going to walk you through the whole process, step by step.

## Step 1: Install & Configure Docker
First things first: You need to install Docker. Here’s an [article](https://docs.docker.com/desktop/install/mac-install/) to help you do it.

Alright, before we jump into installing SQL Server using Docker, here’s a quick but important step – we need to give Docker a bit more memory to work with. Here’s how you do it: First, click on that little Preferences gear icon in the top right corner of your Docker app. Once you’re there, head over to the Resources tab. You’ll see a Memory slider – it’s usually set at 2 GB by default. Let’s bump that up to 4 GB.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/byaqnjlaurn4bb1o2pfh.png)
Just slide that little guy over to the right. Done? Great! Now hit Apply & Restart. That’s it, Docker now has more room to breathe, and we’re all set for a smoother installation.

## Step 2: Install & Setup SQL Server
Ok, folks, it’s go time! We’re now ready to download, set up, and get SQL Server running on your Mac. Here’s the game plan:

First things first, let’s open Terminal. 

Once your Terminal window is up, you’re going to type in this command (it’s a bit of a mouthful, but you’ve got this!):

```
docker pull mcr.microsoft.com/mssql/server:2022-latest
```
Hit Enter, and the download will kick off. Just hang tight for a bit.

After the download wraps up, it’s time to fire up your brand-new SQL Server image in Docker. Here’s the magic command you need:

```
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=strongestPasswordEver123%'-p 1433:1433 -d mcr.microsoft.com/mssql/server:2022-latest
```
A quick note: by typing `ACCEPT_EULA=Y` , you’re giving a thumbs-up to Docker’s end user license agreement.

And voilà, SQL Server should be humming along on your machine. To double-check, click the Docker icon in your menu bar and peek at the Dashboard. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5kya9pobql2ecjoujmie.png)

## Step 3: Install Azure Data Studio & Connect to Your SQL Server Instance
Next up: You need [Azure Data Studio](https://learn.microsoft.com/en-us/azure-data-studio/download-azure-data-studio?tabs=win-install%2Cwin-user-install%2Credhat-install%2Cwindows-uninstall%2Credhat-uninstall). Think of it as the Mac’s answer to SQL Server Management Studio (SSMS). Download it, then drag and drop the Azure Data Studio icon from Downloads to Applications in Finder.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gpyrfmph1w8kfud16so0.png)
Open Azure Data Studio and hit ‘New connection’. Since SQL Server is running on your Mac, just type `localhost` for the server. Your username is `sa` (that’s short for system admin), and the password is what you used in the Terminal command. In our little example here, that’s   `strongestPasswordEver123%` .

And there you have it! You’re all set to rock and roll with SQL Server on your Mac.

Also, just a heads up – even though we’re all about getting Microsoft SQL Server up and running on macOS in this tutorial, there’s no reason you can’t use these same tricks for Docker on Windows or Linux. It’s pretty versatile like that!

And hey, if any of you out there are wizards at cross-platform development with .NET and have some cool tips or sneaky tricks up your sleeve, I’m all ears. Sharing is caring, right? Let’s make this .NET development journey easier for everyone!