Quickly test SQL Server using Docker

SQL Server is a large application. The installation copies lots of files and creates new services. If you want to test a version of SQL Server, you may not want to install it on your computer. Instead of creating a virtual machine, you can get a ready to run image from docker. This is much easier to install and, as a VM, it won't pollute your computer. Indeed, you can remove everything with just one command.

  1. Install feature Container

Install Containers feature

  1. Download and install docker tools
  2. Switch to Windows container

Switch to Windows containers

  1. Get the image you want: mssql-server-windows or mssql-server-windows-express
docker pull microsoft/mssql-server-windows
docker pull microsoft/mssql-server-windows-express
  1. Run the container
docker run -e ACCEPT_EULA=Y -e "SA_PASSWORD=RUc@ysd@f_P*yq4é" -p 1433:1433 --name sqlserver -d microsoft/mssql-server-windows

Note 1: If you already run a SQL Server on you computer, you may need to change the port exposed by the container: replace 1433:1433 by <anotherport>:1433

Note 2: you must use a complex password or you won't be able to connect using the sa account

  1. Check the container is started
docker ps -a

Docker ps result

  1. Connect using SQL Server Management Studio

First, you must download SSMS Then, you must get the IP address of the container:

docker inspect sqlserver | find "IPAddress"":"

container IP address

Finally, you can connect using the IP address and the sa account.

SSMS

Note: if you get an authentication error, you must recreate the container with a stronger password

  1. Delete the container

When you want to delete the container, you have to run the following command:

docker stop sqlserver
docker rm sqlserver

If you want to recreate a new container, go to the step 5. It will take just a few seconds to start 😃