This page looks best with JavaScript enabled

Setup And Run SQL Server Docker Image

 ·  ☕ 3 min read  ·  ✍️ Adesh

Increased Allocated Memory In Docker

Click on Docker icon, and select Preferences.
In the Preferences, select Resources. Here, we need to increase the default allocated memory of the Docker engine to 6GB for SQL Server to run properly. Although allocating 4GB will suffice, however, to obtain better performance, you should allocate as much memory as possible.

docker preferences

Once you have allocated the memory as required, then go ahead and click Apply & Restart. This will restart the Docker engine with the new memory configurations.

Pull SQL Server Docker Image

Now that Docker is up and running, the next step is to pull the official SQL Server Docker image from Docker Hub and get started. Let us create a directory for this exercise and open the terminal in that directory. Once in the directory, run the following command to pull the docker image from the repository to your local machine.

1
docker pull mcr.microsoft.com/mssql/server

Once the SQL Server Docker image has been pulled and extracted, the next step is to start the docker container for this image. A container in Docker is a running instance of the docker image. You can start the container by executing the command as follows.

1
docker run -e ‘ACCEPT_EULA=Y’ -e ‘SA_PASSWORD=password’ -p 1433:1433 -d mcr.microsoft.com/mssql/server

As you can see in the figure above, upon running the command as mentioned in the previous step, an ID is returned. This is the unique ID of the container that is running the SQL Server instance. You can also verify the containers that are currently running by using the command as follows.

SQL Server running in docker

As you can see, the SQL Server Docker container has been created from the image and it is now up and running. Now, the next step is to connect to this instance of SQL Server and issue the SQL commands. Here, you can either use the terminal to connect to the SQL instance or use any GUI-based tool to connect. The most popular GUI tool to connect to SQL Server is the SQL Server Management Studio. However, this tool is only available for Windows and not for MacOS or Linux. Instead, we are going to use another cross-platform tool from Microsoft called Azure Data Studio. This is available to be installed on all the major operating systems like Windows, Linux, and MacOS. You can download this from the below link.

download Azure Data Studio

Read more:

Share on

Adesh
WRITTEN BY
Adesh
Technical Architect