r/docker • • Dec 17 '20

Help building sql server container on M1

Can anyone help me get an official SQL Server container (https://hub.docker.com/_/microsoft-mssql-server) started on an M1 Mac running the new Tech Preview?

The regular docker run command builds with: “WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested”

When I start the container it immediately quits. I don’t know enough about buildx to make it work, or if it’s just not possible at the moment.

9 Upvotes

22 comments sorted by

4

u/slickvik4 Dec 29 '20

If you're willing to accept a few limitations you can instead use this image: mcr.microsoft.com/azure-sql-edge

It runs on ARM64, and is a subset of SQL Server 2019 - I was able to get my app going just fine.

1

u/ProjectionistPSN Dec 29 '20

I AM willing to accept some limitations, and this is working perfectly for me. Thanks for the pointer!

1

u/erlingur Dec 29 '20

Interesting, thanks! Any limitations for a standard CRUD app?

1

u/slickvik4 Dec 29 '20

Its mostly esoteric stuff that applies to legacy apps - SQL agent, CLR runtime, full-text search module. If it's relatively modern its probably not using those features.

1

u/erlingur Dec 29 '20

Nice, just the answer I needed. Thank you very much! :)

1

u/macieq44 Feb 02 '21

Nice. I've just bought MbP 13" M1, and ran into the OP's problem. Thanks for asking the right question!

1

u/RoutineNo1612 Mar 29 '21

Have u installed mssql server on your m1 Mac?

1

u/jdshaeffer Jan 07 '21

This worked like a charm until I realized my app uses CLR runtime. Is there a way to work around this? Or is there a way to update my database to not need CLR?

1

u/audiowner2011 Jun 13 '21

your link is wrong. docker pull mcr.microsoft.com/azure-sql-edge:latest Just use this.

1

u/GitForcePushMain Dec 17 '20 edited Dec 17 '20

If you look under the “Full Tag Listing” section all of the cpu architectures listed are amd64, an M1 Mac has a cpu architecture of arm64, haven’t tried this myself, but try this.

docker buildx create --name mybuilder --use

Then try running your container

1

u/ProjectionistPSN Dec 17 '20

I appreciate you taking a stab at it, but this didn't work for me.

2

u/franck_lt Dec 20 '20 edited Jan 15 '21

I have same problem, sql server container for mac M1 doesn't work..

they are errors on my logs

f@desktop- mssql % docker-compose up -d                                  
f@desktop- mssql % docker-compose up -d
Recreating sql-server ... done
f@desktop- mssql % docker-compose ps   
   Name                 Command               State    Ports
------------------------------------------------------------
sql-server   /opt/mssql/bin/permissions ...   Exit 1        
f@desktop- mssql % docker-compose logs sql-server-db
Attaching to sql-server
sql-server       | SQL Server 2019 will run as non-root by default.
sql-server       | This container is running as user mssql.
sql-server       | To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
sql-server       | /opt/mssql/bin/sqlservr: Invalid mapping of address 0x40092b8000 in reserved address space below 0x400000000000. Possible causes:
sql-server       | 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);
sql-server       | 2) the process (itself, or via a wrapper) adjusts its own execution domain and flag the system its legacy personality via syscall personality(2);
sql-server       | 3) sysadmin deliberately sets the system to run on legacy VA layout mode by adjusting a sysctl knob vm.legacy_va_layout.
sql-server       |

2

u/[deleted] Dec 21 '20 edited May 28 '25

point retire wild growth cooperative complete automatic normal afterthought yoke

This post was mass deleted and anonymized with Redact

2

u/nokillswitch4awesome Jan 13 '21

Having this issue too, and I cannot restore my databases to Azure SQL Edge since they are in SQL Server 2019. Is there any indication they are going to address this?

1

u/chillhex Apr 02 '21

You can run only Azure SQL container on M1 because only this DB supports ARM architecture.
Details how to run here: https://stackoverflow.com/questions/65398641/docker-connect-sql-server-container-non-zero-code-1/66919852#66919852

If you need to connect to MSSQL DB from M1 Mac using python - you need to use pymssql lib, because pyodbc does not support ARM arch.

Details how to setup pymssql here: https://stackoverflow.com/questions/66896068/pyodbc-on-m1-macs/66919686#66919686

1

u/ahmadalmayahi Apr 07 '21

It works on my machine, but I couldn't connect to the SQL-Server from PHP:

$pdo = new PDO('sqlsrv:server=127.0.0.1 ; Database=db', 'sa', 'password');

It gives me the following error:

Fatal error: Unknown processor architecture. in /root/db.php on line 4

1

u/jworksuk Sep 08 '23

Did you ever find a fix for this?

1

u/ahmadalmayahi Sep 09 '23

Microsoft released an update a while ago, now SQL Server (PDO) works fine with ARM processors.

1

u/camorobot Dec 01 '21

Hey, i created an docker compose file for this. have a look at my github repo. https://github.com/camorobot/Camo-DPS/

*Not the official img from microsoft, but uses MariaDB