You cant really use mcr.microsoft.com/mssql/server:2019-latest
containers on M1 because MSSQL DB does not support ARM architecture. The only way I found – is to use Azure SQL container that supports ARM and can be run on M1.
Here my docker-compose.yml
config example:
version: "3.9"
services:
# Database instance
mssql:
image: mcr.microsoft.com/azure-sql-edge:latest
volumes:
- events_mssql:/var/opt/mssql
ports:
- 1433:1433
environment:
- ACCEPT_EULA=1
- MSSQL_SA_PASSWORD=Passw@rd
volumes:
events_mssql:
You will be able to connect to this DB using username: sa
, password: Passw@rd
and database: master
. If you want other db name – you can create a new one using SQL: CREATE DATABASE TestDB
This database has the same API as MSSQL DB, so it works with pyodbc
(not supported on M1) and pymssql
libraries.
If you are using it locally on your M1 machine – consider using pymssql
library for connection to Azure SQL DB. Here my answer on issue with pyodbc
https://stackoverflow.com/a/66919686/11515610