Bobcares

Set Up a Local SQL Server on an M1 Mac Using Docker

PDF Header PDF Footer

Learn how to set up a Local SQL Server on an M1 Mac using Docker. Our SQL Server Support team is ready to assist.

Set Up a Local SQL Server on an M1 Mac Using Docker

Set Up a Local SQL Server on an M1 Mac Using DockerRunning Microsoft SQL Server natively on an M1 Mac might sound impossible at first. Microsoft doesn’t offer a native ARM-based macOS version. Fortunately, we can easily set up and manage SQL Server on your Apple Silicon Mac for local development with Docker.

Today, we will walk through each step to get SQL Server running on the M1 Mac using Docker.

Prerequisites

Before diving in, we need the following:

  • An M1 Mac
  • Administrative privileges
  • A stable internet connection
  • Docker Desktop for Mac
  • Minimum 4 GB RAM allocated to Docker. SQL Server needs at least 3.25 GB.
  • Node.js & npm (optional): Needed if you want to use the `sql-cli` tool.
  • Azure Data Studio

Step 1. Install Docker Desktop

First, download and install Docker for Mac:

  1. Visit the Docker website and download Docker Desktop for Mac, which supports Apple chip architecture.
  2. Then, install Docker by dragging the `.dmg` file into the Applications folder.
  3. Launch Docker Desktop and install Rosetta 2 if prompted, using:
    softwareupdate –install-rosetta

By default, Docker only allocates 2 GB of RAM. We need to increase this to at least 4 GB:
So, go to Settings under Resources and move the Memory slider to 4 GB or higher. Then, click Apply & Restart.

Step 2: Pull the SQL Server Docker Image

We have two ARM-compatible options to run SQL Server:

  • Option A: Use Azure SQL Edge (ARM-Optimized)
    docker pull mcr.microsoft.com/azure-sql-edge
  • Option B: Use the 2022 SQL Server Image (for x64 via emulation)
    sudo docker pull mcr.microsoft.com/mssql/server:2022-latest

 

If you’re encountering issues like port binding or connection refusal, you might want to look into common problems such as the SQL Server not listening on port 1433.

Step 3: Run the SQL Server Container

Launch SQL Server in Docker using one of the following commands:

  • For Azure SQL Edge:

    docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=YourStrongPassword!" \
    -p 1433:1433 --name sqlserver \
    -d mcr.microsoft.com/azure-sql-edge
  • For SQL Server 2022:

    docker run -d --name sql_server_test \
    -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=dockerStrongPwd123' \
    -p 1433:1433 mcr.microsoft.com/mssql/server:2022-latest

Step 4. Verify the SQL Server Container

To ensure everything is working, run this command:

docker ps

Look for the container in the running list.

Step 5. Connect to SQL Server

First, install `sql-cli` globally using `npm`:

sudo npm install -g sql-cli

Then, connect:

mssql -u sa -p dockerStrongPwd123

Now, try a test query:

SELECT @@VERSION;

If you encounter errors such as “Pre-login handshake failed”, this troubleshooting guide on pre-login handshake errors might help.

Alternatively, download Azure Data Studio. Then, open the app and create a new connection:

  • Server: `localhost`
  • Username: `sa`
  • Password: `dockerStrongPwd123`
  • Click Connect, and we can run SQL queries in a visual environment.

Once connected, you may occasionally run into SQL errors. For instance, if you’re working with complex joins and encounter an ambiguous column name error, here’s a detailed guide to fixing ambiguous column name issues in SQL Server.

Step 6. Restarting and Managing Your Server

To stop the container:

docker stop sql_server_test

To restart it:

docker start sql_server_test

Then reconnect using `sql-cli` or Azure Data Studio as before.

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

Running SQL Server on an M1 Mac may not be natively supported, but Docker makes it possible.

In short, our Support Engineers demonstrated how to set up a Local SQL Server on an M1 Mac using Docker.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Get featured on the Bobcares blog and share your expertise with a global tech audience.

WRITE FOR US
server management

Spend time on your business, not on your servers.

TALK TO US

Or click here to learn more.

Speed issues driving customers away?
We’ve got your back!