So, with all the excitement I set up the new development environment on my brand new Macbook Pro M1, happily clone my package https://github.com/kitloong/laravel-migrations-generator, develop and run test, then I found myself in a trouble:
The SQL dockers stopped working!
With the help of Google, I was able to fix the MySQL and PgSQL dockers by adding:
platform: "linux/amd64"
However, this does not fix SQL Server 2019.
Further investigation lead me to this issue https://github.com/microsoft/mssql-docker/issues/668
Long story short, SQL Server 2019 does not support ARM. To run SQL Server on M1 we need to use Azure SQL Edge, but Azure SQL Edge has a few missing features:
Luckily, as suggested and inspired @Meligy, I install Debian 11 AMD64 in UTM, install Docker and SQL Server 2019 on Debian, then port forward 1433 so that local application on Mac M1 could connect successfully.
Prerequisite
First of all, you need to download UTM and Debian 11 respectively,
then, launch UTM to begin the setup.
Setup VM
- On the UTM interface, click add VM to open dialog, select “Emulate” > “Linux” > Browse and select the downloaded Debian iso.
- Leave everything to default and save.
- Before you run the VM, let’s confirm the configuration. You should have:
4. Port forward 22 is for ease of ssh and 1433 is reserved for SQL Server.
5. With the above configured, run the VM and complete the setup. You could follow this article to complete the installation.
Make sure you install ssh server to allow ssh access from local. Also, you could skip GUI, the GUI itself consumed about 3GB.
Install Docker
- After Debian was installed and booted successfully, we can ssh and run commands from the local terminal.
ssh debian@localhost -p 22022
2. You could follow the Docker installation from here, here’s my executed commands for installation.
# Remove previous Docker
sudo apt-get remove docker docker-engine docker.io containerd runc# Install packages
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release# Set up the repository
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpgecho \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullsudo apt-get update# Install Docker
sudo apt-get install docker-ce docker-ce-cli containerd.io# Test Docker
docker run hello-world
Additional: Sudoer
If you found yourself having trouble running sudo
command, kindly follow this article to fix the issue.
Install SQL Server
- Docker pull SQL Server
sudo docker pull mcr.microsoft.com/mssql/server:2019-latest
2. Run SQL Server
sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<STRONG_PASSWORD>" \
-p 1433:1433 --name mssql \
-d mcr.microsoft.com/mssql/server:2019-latest
That’s it, you are now running SQL Server 2019 on Mac M1!
If you are following the port forwarding from the previous screenshot, SQL Server is now accessible from port 14333.
Now I can continue SQL Server-related development, I will be glad if this article can solve your issue too!
References
- https://github.com/microsoft/mssql-docker/issues/668
- https://www.tecmint.com/install-debian-11-minimal-server/
- https://www.codeluge.com/post/setting-up-docker-on-macos-m1-arm64-to-use-debian-10.4-docker-engine/
- https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker?view=sql-server-ver15&pivots=cs1-bash
- https://phoenixnap.com/kb/how-to-install-docker-on-debian-10
- https://linuxhint.com/how-to-fix-debian-sudo-command-not-found/