Sony Arouje

a programmer's log

Archive for the ‘Programming’ Category

Configure MS Sql Server in Mac M1 via docker

leave a comment »

In this post, I will walk you through how to run MS Sql Server on Mac M1. Make sure docker desktop is installed on your machine.

I prefer using a Docker Compose file to run containers because it helps me avoid remembering all the environment variables, ports, and configurations.
To run SQL Server, I’ve created the following Docker Compose file:

version: '3.8'

services:
  sqldata:
    image: mcr.microsoft.com/mssql/server:2022-latest
    environment:
        - SA_PASSWORD=Pass@word
        - ACCEPT_EULA=Y
    container_name: sqlserver-tracer
    ports:
        - "1433:1433"
    volumes:
        - './data:/var/opt/mssql/data'
        - './log:/var/opt/mssql/log'
        - './secrets:/var/opt/mssql/secrets'

Now, run the following command to start the SQL Server container:

docker-compose up

The container will exit with following error code

This container is running as user mssql.
To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
/opt/mssql/bin/sqlservr: Invalid mapping of address 0x400976b000 in reserved address space below 0x400000000000. Possible causes:
1) the process (itself, or via a wrapper) starts-up its own running environment sets the stack size limit to unlimited via syscall setrlimit(2);
2) the process (itself, or via a wrapper) adjusts its own execution domain and flag the system its legacy personality via syscall personality(2);
3) sysadmin deliberately sets the system to run on legacy VA layout mode by adjusting a sysctl knob vm.legacy_va_layout.

To fix the above error, follow these steps in Docker settings:

General -> check Use Virtualization framework
Features in development -> Use Rosetta for x86/amd64 emulation on Apple Silicon

Now, run the Docker Compose command again, and this time SQL Server should be up and running.

DB Management tool

Download Azure Data Studio

Create a new connection, keeping in mind that the server parameter should be set to something like localhost,1433, where 1433 is the port mentioned in the Docker Compose file.

  • User Name: sa
  • Password: specify the password configured in docker compose environment variable SA_PASSWORD
  • Leave the database as default.

Note: This tutorial assumes that you have Docker Desktop installed on your Mac. If you haven’t already, you can download it here. Additionally, make sure you have a basic understanding of Docker and its concepts, as we’ll be using Docker Compose to manage our SQL Server container.

Written by Sony Arouje

September 21, 2023 at 4:56 pm

Posted in Misc, Programming

Tagged with , ,