SQL Server on Linux via Docker
Reference post for getting SQL Server Linux up and running
-
Get Docker (if it is not already running)
-
Get the SQL Server on Linux for Docker Engine image
I'm running Docker on MacOS, I will use the SQL Server on Linux for Docker Engine at Docker Hub
docker pull microsoft/mssql-server-linux
-
Set the settings and start the container
SQL Server on Linux for Docker Engine requires an environment setting to accept the EULA and set a strong SA password:
ACCEPT_EULA = Y SA_PASSWORD = <your password>
Run this in the terminal:
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -d microsoft/mssql-server-linux
-
Copy a backup to the container
docker cp '/tmp/DatabaseName.bak' mssql-server-linux:/tmp
-
Restore the backup
RESTORE DATABASE DatabaseName FROM DISK='/tmp/DatabaseName.bak' WITH MOVE 'DatabaseName' TO '/var/opt/mssql/data/DatabaseName.MDF', MOVE 'DatabaseName_log' TO '/var/opt/mssql/data/DatabaseName_log.ldf' Go
-
Connect with a docker command or an IDE like DataGrip
Using SQL Server for Linux in Docker has allowed me to continue to develop using a Linux distro or macOS without needing to set up a VM to run the database backend.
This post and/or images used in it may have been created or enhanced using generative AI tools for clarity and organization. However, all ideas, technical work, solutions, integrations, and other aspects described here are entirely my own.