Quickly test SQL Server using Docker

  • Gérald Barré

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 featureInstall Containers feature

  2. Download and install docker tools

  3. Switch to Windows container

    Switch to Windows containersSwitch to Windows containers

  4. 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
  5. 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

  6. Check the container is started

    docker ps -a

    Docker ps resultDocker ps result

  7. 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"":"

    Get the container IP addressGet the container IP address

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

    Connect to the SQL Server server using SQL Server Management StudioConnect to the SQL Server server using SQL Server Management Studio

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

  8. 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 step 5. It will take just a few seconds to start 😃

Do you have a question or a suggestion about this post? Contact me!

Follow me:
Enjoy this blog?Buy Me A Coffee💖 Sponsor on GitHub