DEV Community

David
David

Posted on

How to run SQL Server on M1/M2 with Docker

Pull the image by opening up a terminal and running the command

docker pull mcr.microsoft.com/azure-sql-edge`
Enter fullscreen mode Exit fullscreen mode
docker run --cap-add SYS_PTRACE -e 'ACCEPT_EULA=1' -e 'MSSQL_SA_PASSWORD=your_strong_password' -p 1433:1433 --name azuresqledge -d -v sqlvolume:/var/opt/mssql mcr.microsoft.com/azure-sql-edge
Enter fullscreen mode Exit fullscreen mode

–cap-add SYS_PTRACE – here is Microsoft’s note on this line: The --cap-add SYS_PTRACE flag is required for non-root SQL Server containers to generate dumps for troubleshooting purposes

-e ‘ACCEPT_EULA=1’ is an environment variable, which is saying that we will accept the End User License Agreement.

-e ‘MSSQL_SA_PASSWORD=your_strong_password’ – this is setting the password for the sa (the system administrator) user. This is how you will log into the database. By default the username is ‘sa’.

-p 1433:1433 is mapping ports. The left side of the colon is the port on the host (your mac). The right side is the port used inside the container

–name azuresqledge is just giving the container a more user-friendly name after it starts running

-d is detached mode. This means that the terminal won’t attach to the process, which means it’ll start the container up and then give you terminal control back, so you can run other commands.

-v sqlvolume:/var/opt/mssql is to persist the data

mcr.microsoft.com/azure-sql-edge is last and it’s the name of the image. This is the same name used in the docker pull command

Top comments (0)