First, pull the Azure SQL docker image1:
docker pull mcr.microsoft.com/azure-sql-edge:latest
Then, start the database. The following command assepts the EULA, sets the SQL Server Edition to Developer the sets the password to Password12.
docker run -d \ -e "ACCEPT_EULA=Y" \ -e "MSSQL_PID=Developer" \ -e "MSSQL_SA_PASSWORD=Password1" \ -p 1433:1433 \ --name azure-sql-edge \ mcr.microsoft.com/azure-sql-edge
Generate the Rails application, selecting MSSQL by passing sqlserver as the database:
rails new . --database sqlserver
Then, prepare the database and start the server, supplying the password by exporting SA_PASSWORD
:
export SA_PASSWORD=Password1 rake db:prepare ./bin/rails s
Welcome aboard! You’re riding Ruby on Rails with MSSQL.
I switched to
mcr.microsoft.com/azure-sql-edge
after usingmcr.microsoft.com/mssql/server
before, but it started having ARM-related issues when switching computers:2024-05-01 11:50:01 SQL Server 2022 will run as non-root by default. 2024-05-01 11:50:01 This container is running as user mssql. 2024-05-01 11:50:01 To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216. 2024-05-01 11:50:01 /opt/mssql/bin/sqlservr: Invalid mapping of address 0x2aaaad74d000 in reserved address space below 0x400000000000. Possible causes: 2024-05-01 11:50:01 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); 2024-05-01 11:50:01 2) the process (itself, or via a wrapper) adjusts its own execution domain and flag the system its legacy personality via syscall personality(2); 2024-05-01 11:50:01 3) sysadmin deliberately sets the system to run on legacy VA layout mode by adjusting a sysctl knob vm.legacy_va_layout. 2024-05-01 11:50:01
I opted to switch to the Azure image, which isn’t emulated and has been working fine for my purposes.
↩︎There are password restrictions when starting the database. My first try was test, which wasn’t accepted because it was too short:
2024-05-01 10:00:24.97 spid25s ERROR: Unable to set system administrator password: Password validation failed. The password does not meet SQL Server password policy requirements because it is too short. The password must be at least 8 characters..
Then, password didn’t work:
2024-05-01 10:08:26.34 spid25s ERROR: Unable to set system administrator password: Password validation failed. The password does not meet SQL Server password policy requirements because it is not complex enough. The password must be at least 8 characters long and contain characters from three of the following four sets: Uppercase letters, Lowercase letters, Base 10 digits, and Symbols..
Finally, adding a capital letter and a number by making the password Password1 worked!
↩︎