I've made the decision to investigate and experiment with the docker. I therefore considered learning and imparting knowledge to others while I was doing it. Thus, I installed Docker on Windows 11 and used it to run the MS SQL server in this article.

Requirements

A laptop with at least 8 GB of RAM
Set up the docker
MS SQL Server Management Studio
After successfully installing the docker you need to sign into the Docker Hub. https://hub.docker.com/
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?
"Docker is an open platform for developing, shipping, and running applications," according to the Docker documentation. Docker allows you to rapidly release software by separating your apps from your infrastructure. You can use Docker to manage your infrastructure in the same manner that you do your apps. You may cut down on the amount of time it takes between writing code and having it run in production by utilizing Docker's shipping, testing, and deployment processes."

We can run the applications without caring about the underlying environment thanks to Docker. Since we can use that in the Docker application, we'll include all dependencies and necessary files in the container.

You've been curious about what a container is
Code can be executed in an isolated environment using a container. In other words, the container operates in the context where Docker Desktop is available, without any knowledge of the underlying operating system or files.

Docker Hub
It's a registry for Docker images hosted in the cloud. Users may share, search, and control Docker images with it. For developers wishing to create and launch apps using Docker, Docker Hub is a well-liked option.

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. https://hub.docker.com/_/microsoft-mssql-server

As I previously stated, the MSSQL Server is operating on Ubuntu, but my base environment is Windows 11. The photograph is available at the aforementioned URL. The command on the page to the command prompt must be used.

docker pull mcr.microsoft.com/mssql/server:2022-latest

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  mcr.microsoft.com/mssql/server:2022-latest

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

You must launch the MS SQL Server Management Studio and fill in the fields displayed in the screenshot in order to access the SQL Server.


Both the password and the username, SA, must be entered. Once your authentication has been successful, you can query the system databases.

That's all I have for now; in the next post, I'll demonstrate how to link this database to the.NET applications. Please let me know if you have any problems completing the aforementioned tasks.

HostForLIFE.eu SQL Server 2022 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.