Run SQL 2019 in Docker
SQL 2019 RC1 is now generally available and I wanted to try it out. Instead of installing it on my PC, I decided to give it a go in Docker. After a bit of mucking around, I worked out the following:
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=C0mplexP@ssword" -v 's:\:/var/opt/mssql/data/mydata' -p 1433:1433 --name sql1 -d mcr.microsoft.com/mssql/server:2019-RC1-ubuntu
Getting SQL up and running took a matter of minutes. You find the docker path, set a password, assign the port, come up with a name and tell docker to run it. Docker downloads it and starts it up and you have a SQL 2019 server you can connect to!
The complex part for me was working out how to make available the drives that I have my test databases stored on. One of my test databases is the StackOverflow2018 database – at just over 300GB it’s not something I can easily just throw around on my C drive, I have it attached via iSCSI to NAS and mapped as S drive.
I finally worked it out that you need to map your local drive to the /var/opt/mssql/data/something folder. I found if I mapped it anywhere else I couldn’t find the files to attach.
Once Docker has started the server you can connect to it via SSMS like a normal instance using the sa password you picked. From SSMS it’s easy to attach (via SQL or UI) your existing databases.
This is definitely the simplest and quickest SQL Server I have stood up. I would still be very cautious about standing up a server in a production environment this way, but it’s brilliant for local PCs.