I just reinstalled my PC and needed a database for some simple work. I did not like the idea of installing a full SQL Server on my PC. Too heavy and takes too long. The I remembered that Microsoft recently announced that they can run SQL Server on Linux and they even have a Docker Container for it. That seemed like a good idea to me.
On my PC I have the “Docker for Windows” tools running. What this actually is, is a very small Linux machine running in Hyper-V that can run Docker Images. I opened my command line and typed
docker search mssql
The first image is the right one, so I pulled this one to my local PC
docker pull Microsoft/mssql-server-linux
Once I had done that, I had to find a way of running the container. When you go to DockerHub, and look for the same image, you can also find some more info. https://hub.docker.com/r/microsoft/mssql-server-linux/
There it show the command you need to run the image, however this does not work in a Windows Command line because of the quotes. The Environment variables need to be enclosed in “Double” quotes instead.
Further more, it runs on port 1433, this is fine in most cases, but I decided to run on a different port to avoid any mistakes when something was already running.
I executed the command
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Welkom1234!" -d -p 1500:1433 microsoft/mssql-server-linux
but it did not work. Because the -d switch ensures it runs in the background, you have no clue, so I looked in interactive mode.
docker run -e “ACCEPT_EULA=Y” -e “SA_PASSWORD=Welkom1234!” -ti -p 1500:1433 microsoft/mssql-server-linux
Now it showed, that the server needs at least 3,25 Gb to start SQL Server.
In order to fix this, you need to go to the Docker for Windows Console and change the Memory of the Linux “host server”, not the memory of the container.
After that you can run the command again (with the -d switch) and you have a SQL Server in a second..
SQL Management Studio
Because I am still a graphical guy, I installed SQL Server Management Studio (https://msdn.microsoft.com/en-us/library/mt238290.aspx) . After installing you can connect to your SQL Server by typing
127.0.01, 1500 (mind the comma instead of a colon for the port), SA as username and your password from the environment variable in the docker run command
SQL Server up in less than 5 minutes! Woohoo !
Docker for Windows – https://docs.docker.com/docker-for-windows/
MS SQL on Linux Docker Image – https://hub.docker.com/r/microsoft/mssql-server-linux/