MacBook Pro with Apple silicon is a great laptop for developers with impressive performance and energy efficiency, but you still could face some compatibility issues when trying to run specific software. One of such examples is running Microsoft SQL Server on Docker.
What happens if you try to run it using default example command from https://hub.docker.com/_/microsoft-mssql-server?
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=yourStrong(\!)Password" -p 1433:1433 -d mcr.microsoft.com/mssql/server:2022-latest
You’ll get a warning like the one below and won’t be able to connect to your server. This is because your host platform is using ARM chip and Docker container with SQL Server is based on linux/amd64 platform.
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 58ea2a3c48359b74b908e00a91fcc0c5fa180a4d3a5f206b279486694b1432b4
Let’s add specific platform to docker run program to fix a warning.
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=yourStrong(\!)Password" -p 1433:1433 --platform=linux/amd64 -d mcr.microsoft.com/mssql/server:2022-latest
The program completed successfully, but you still unable to connect to SQL Server. Defining platform just helped to fix a warning, but not a root cause. Let’s see the container status.
docker container ls -a
It shows, that it exited and not running.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9febab655658 mcr.microsoft.com/mssql/server:2022-latest "/opt/mssql/bin/perm…" 30 seconds ago Exited (1) 29 seconds ago frosty_grothendieck
To figure out, what exactly happened, we can investigate logs of out conrainer.
docker logs 9fe
And you’ll see some strange errors:
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 0x400384a000 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 it, you’ll need to go to Docker Desktop settings and set “Use Rosetta for x86/amd64 emulation on AppleSilicon” in “Features in development” section.
That’s it. Now, you’ll be able to run SQL Server on Apple Silicon without errors.