Microsoft SQL Server on Docker on Apple Mac Silicon

Screenshot of Docker

While reinstalling my system I needed to have Microsoft SQL Server running on my new Apple Mac (which contains an M2 chip). There are various posts online about this, but the following worked for me.

  1. Install Docker Desktop
  2. Go to the settings and find the "Features in Development" tab and enable "Use Rosetta for x86/amd64 emulation on Apple Silicon"
Screenshot of Docker Desktop. On the left it has the "Features in Development" selected and on the right it first shows the "Beta features" under which various options are listed. The option with "Use Rosetta for x86/amd64" emulation on Apple Silicon is turned on
Screenshot of where to find the setting in Docker Desktop

Once done you can get Microsoft SQL Server running on you machine by simply executing the following commands:

# Pulls the image
docker pull mcr.microsoft.com/mssql/server:2022-latest
# Starts the server
# NOTE: The `--platform linux/amd64` ensures that it runs in the correct mode
# NOTE: The Password must be strong, so please change 
docker run --platform linux/amd64 -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=DevPassword123" -p 1433:1433 --name sql1 --hostname sql1 -d mcr.microsoft.com/mssql/server:2022-latest

After all that simply run your favorite tool for connecting to the database and it should work.