Quickly test SQL Server using Docker

 
 
  • Gérald Barré

SQL Server is a large application. Installing it copies many files and creates new services. If you just want to test a version of SQL Server, you probably don't want a full installation on your machine. Instead of setting up a virtual machine, you can use a ready-to-run Docker image. It is much easier to get started and, unlike a VM, it keeps your computer clean. You can remove everything with a single 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

    Shell
    docker pull microsoft/mssql-server-windows
    docker pull microsoft/mssql-server-windows-express
  5. Run the container

    Shell
    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 have SQL Server running on your computer, you may need to change the port exposed by the container: replace 1433:1433 with <anotherport>:1433

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

  6. Check the container is started

    Shell
    docker ps -a

    Docker ps resultDocker ps result

  7. Connect using SQL Server Management Studio

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

    Shell
    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, recreate the container with a stronger password.

  8. Delete the container

    When you want to delete the container, run the following commands:

    Shell
    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?