Run MS SQL Server on Docker 📦

I've decided to explore the docker and do some experiments with it. So, while doing that, I thought of learning and sharing the knowledge with others.

So, In this article, I have installed the Docker on Windows 11 and also ran the MS SQL server in the docker.


Laptop with 8 GB RAM Minimum

Docker. You can refer to the link to download & install the docker

MS SQL Server Management Studio

After successfully installing the docker you need to sign into the Docker Hub.

Before you move to the next step, you need to learn some basics about Docker & the norms and nuances used in it.

What is Docker?

As per the Docker Documentation, "Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. By taking advantage of Docker's methodologies for shipping, testing, and deploying code, you can significantly reduce the delay between writing code and running it in production."

You can learn more about the Docker from the Official Documentation:

Docker allows us to run the applications without worrying about the underlying environment. Because we'll include all the dependencies, and required files to be included in the container and we can use that in the docker application.

You have wondered what is a Container.

A container is an isolated environment to run your code. By means, the container doesn't know about the underlying OS & the files and it runs on the environment in which the Docker Desktop is provided.

Docker Hub

It's a cloud-based registry for Docker images. It allows users to search, share, and manage Docker images. Docker Hub is a popular choice for developers who want to use Docker to build and deploy applications. You can log into the Docker hub on this link

Ok, done with our theory. Let's dive into the hands-on.

How to Run MS SQL Server on Docker

We need to find the MSSQL Server image that runs on the Ubuntu.

As I mentioned earlier, My underlying environment is Windows 11 but the MSSQL Server is running on the Ubuntu. You can find the image on the above URL.

You need to use the command on the page to the command prompt

docker pull

You'll face the error when the Docker Deamon is not running.

Otherwise, it'll look like this.

Use the command, to show the images available

docker images

You can also see the same image on the Docker Desktop too.

Now, you need to install the MSSQL Image on the Docker using the below command

docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=<StrongPassword>" -p 1433:1433 --name sql1 --hostname sql1 -d

You need to set the ACCEPT_EULA variable to Y to accept the end user license agreement and the SA_PASSWORD variable to a strong password for the system administrator account.

After the successful login, you can able to see the container running in the Docker Desktop

To access the SQL Server, you need to open the MS SQL Server Management Studio and enter the fields shown in the screenshot

You need to enter the password and the username as SA. Then you can successfully authenticated and able to query the system databases.

That's all for today and I will show how to connect this database to the .NET applications in the next article. Let me know if you are facing any issues while following the above-mentioned steps.

Similar Articles