Docker is now a big part of our development lifecylce at Cortex and I have previously posted about setting up a local Docker dev env.

One of the key components of our Docker dev sandboxes is the database. The majority of our applications use SqlServer, and having each developer being able to spin up their own SqlServer instance and be able to work away without fear of breaking things for others is key. With Docker we have become used to being able to tear down the database and create a fresh instance inside 20 seconds. This has changed the way that we develop and our database creation (refresh dev) and upgrade scripts (that are applied to test / prod envs) are easy to test and therefore easily kept in sync. The sacrifices to the release gods ahead of upgrading test / productions systems seem a long time ago!

Where am I going with all this?! Docker is something that I’ve started taking for granted. After upgrading my home setup to an Apple M1 Studio, I was looking forward to the bump in processing power and being able to make it my primary development machine outside of the office.

Picture my happy little face as I kicked off the build scripts to rebuild my dev environment:

  • Background scheduler built and launched inside .net6 linux container
  • Web application built and launched inside a .net 6 linux container
  • Database image pulled down and the image built…

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

Can’t be terminal surely!?

A quick, come lengthy google search and hours of reading through github issues confirms that SqlServer is not supported on Apple Silicon.

There were lots of helpful suggestions that we cut across to use Azure Sql-Edge instead as this works on Apple Silicon. Alas this is not feasible.

  • All of our applications/products run on full fat azure Sql Server
  • All of our local development environments are fully scripted and use full fat sql server

This means that we depend on scripts like this one and sqlcmd which isnt available in azure-sql-edge…

#run the setup script to create the DB and the schema in the DB
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P !Shhhh123 -d master -i dev-db.sql
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P !Shhhh123 -d dev-db -i setup-dev-db.sql

echo "Created a dev bragi meta DB shell (tables and sprocs) + bare minimum settings and config."

# Seed the DB with some sample content from seeker
echo "Loading: Seed the test data"
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P !Shhhh123 -d dev-db -i ./test-data/TestData.sql

Set up Docker desktop

  1. Settings => General Use Virtualiszation framework
  1. Settings => Features in development Use Rosetta for x86/amd64 emulation on Apple Silicon

With these two settings you will be able to run docker images.

docker run --platform=linux/amd64 --name MySqlServer -e ACCEPT_EULA=1 -e MSSQL_SA_PASSWORD=Shhhh123 -p 11433:1433 -d

Docker compose still failing?

When launching containers via Docker compose then you will still encounter the same The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) error message.

✔ Volume "bragidev_mssqlbragidatabase"      Created    0.0s
✔ Container bragidev-bragi-db-1             Started    0.2s
! bragi-db The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 0.0s

This continues to fail as the --platform argument is not being set and it will instead be arm64 (M1). You can change this by setting the DOCKER_DEFAULT_PLATFORM environment variable.

    export DOCKER_DEFAULT_PLATFORM=linux/amd64

Once this has been set then you can docker-compose up and your sqlServer container will fire up!

Right, let’s see what these Apple Silicon chips are capable of!