Microsoft is pretty upfront about the fact SQL Server doesn’t run natively on macOS. Back in college, I learned this the hard way. I bought a Windows license, spun up a VirtualBox VM on my 8GB MacBook Pro, and limped my way through installing SQL Server 2016 for a database class. It was miserable.
If only 2015 Chandler knew about Docker.
What is Docker?
If you’ve used virtual machines, think of containers as a leaner, more efficient alternative. Instead of virtualizing hardware and running a full-blown OS for every instance, containers share the host system’s kernel and isolate the app at the process level. Basically in our case, it’s SQL Server in a pre-packaged box. Docker runs on Windows, Linux, and MacOS.
Installing Docker
Macs now come in two flavors: Intel and Apple Silicon. Docker Desktop supports both, but setup steps differ slightly. Follow the official Docker Desktop install guide and make sure to pick the version that matches your architecture.
After installing, open Docker and either sign in or create a new account.
Install SQL Server
Actually deploying the SQL Server is incredibly easy, and why it’s worth it over a VM in this use case. Just open the Terminal and run the following commands:
docker version
If that fails with -bash: docker: command not found, Docker may not be in your system’s PATH. I fixed this with:
sudo ln -s /Applications/Docker.app/Contents/Resources/bin/docker /usr/local/bin/docker
If docker version
still doesn’t display the proper output, Google is your best friend. Once those issues are resolved, you’ll run the following command to pull SQL Server 2022.
docker pull mcr.microsoft.com/mssql/server
Once that completes, run this to run your SQL Server. Edit the password before running:
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=<password>" \
-p 1433:1433 --name sql1 --hostname sql1 \
-d \
mcr.microsoft.com/mssql/server:2022-latest
This shouldn’t take too long to complete, but once it’s done, you have SQL Server 2022 running on your local machine on port 1433.
What now?
This setup isn’t meant for production, but it’s perfect for local testing, development, and learning. If you’re curious to explore further, check out Docker Hub and the official Microsoft SQL Server on Linux docs.
So that’s it: SQL Server on your Mac, no VM, no problem. If you’ve made it this far, congrats! You’ve officially bypassed 2015 me and saved yourself 4GB of RAM and a little bit of your soul.
Just don’t forget your sa password. Or do, and relive the setup all over again. Your call.