Running a Docker SQL Server Linux Container in Windows 10
Running SQL Server on Linux is great for testing. There's no reason that functionality shouldn't be available to Windows users either.
Join the DZone community and get the full member experience.Join For Free
Microsoft is making a huge effort to bring SQL Server 2016 to Linux. Back in the summer, during the Dublin 2016 SQL Saturday #501, Mark Souza presented the SQL Server history. One of the major features is the ability to run SQL Sever 2016 on Linux.
Since then I added on my TODO list a simple task — test SQL Server in Linux. The best way to do it is using a Docker container. Plus, since the last time that I played with Docker in Windows, they've begun to run on Hyper-V instead of VirtualBox. For me, this is a huge improvement in the product, as we do not need several virtualization technologies on my development machine.
After installing the latest version of Docker (at the time of this post is 1.12.5), I start to read the notes on how to run the SQL Server Docker container. The first thing that jumped was this instruction:
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' -p 1433:1433 -v HOSTDIRECTORY:/var/opt/mssql -d microsoft/mssql-server-linux
Especially the port assignment, since I’ve got SQL Server installed on my development machine using the standard port 1433. I’ve modified the instruction to be:
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' -p 7000:1433 -v C:\Temp\Docker\mssql:/var/opt/mssql -d microsoft/mssql-server-linux
Where I assigned the public port 7000 to the container port 1433 (SQL Server default), and the container will persist the files in my file system at C:\Temp\Docker\mssql.
Opening SQL Server Management Studio, I can connect using my credentials:
After connecting, just run the famous command:
And get the results:
I’ve played around for a few hours, and it is a good candidate to start the test for a production environment. I’ve tried a few applications and all of them worked without any problem. Good work SQL team, keep them going!
Published at DZone with permission of João Rosa, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.