Przejdź do głównej zawartości

Running Microsoft SQL Server on Linux with Docker

Probably you heard that Microsoft Sql Server can only run on Windows machines. Good news - This is not true anymore. You can easily install it on Linux machine too.
In this article I show you 2 ways of installing Sql Server on Ubuntu 16 and demonstrate how to connect to the database from remote machine.

OPTION 1: Slow way - Manual installation
This is the most straightforward way of installing. You download packages and configure Sql Server interactively(you set password, port and choosing installation option - free or paid).
This is the step by step instruction from microsoft
https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu

OPTION 2: Fast way - Running on docker with just 2 pure-command-line commands.
My assumption is that your Ubuntu machine has already docker installed.
You can check if Docker is already installed by tunning the command: docker.
If you don't have docker installed, no problem: before continuing below instruction just install docker. This article shows how you can do it: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04

Go to Docker Hub, which is a public docker images repository(something like nuget gallery for .NET packages).

You can search for Microsoft Sql Server images. One of the result will be mssql server for linux:
https://hub.docker.com/r/microsoft/mssql-server-linux/

Now you need to download image to your linux machine by running the following command:
docker pull microsoft/mssql-server-linux
The result should be as follows:

The final step is to run docker container based on the image you just have downloaded:
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -d microsoft/mssql-server-linux

Remember that you need to modify the above command a little bit. Just set the password to a string that you'll be using in order to connect to database.
When you run the command the SQL Server will run on 1433 port. Note that we specify this port 2 times. This is because we specify port inside of container and outside of container.

When you're done then congratulatiions - Your first SQL Server is running on your Linux machine.


Final step: Connect to SQL Server:
Now you can easily connect to your SQL Server database from Sql Server Management Studio(Exactly the same way like it was any windows-based installation).
To establish a connection you need the following data:
- IP address of your linux machine
- Port number where you started Sql Server - in our case it's 1433
- User Password - this is the password that you used when you've started the container.






Komentarze

Popularne posty z tego bloga

Unleash the power of ChatGPT in your C# applications with NGpt - C# OpenAI GPT client

Meet NGpt - OpenAI GPT C# client library that will make your conversations with ChatGPT a breeze! Have you ever been struggling building your own smart AI application in C#? Well, now you can use ChatGpt inside your application! Introducing NGpt, the powerful .NET library that lets you integrate ChatGPT seamlessly into your C# applications. No more nigts spent on building your own AI solitions, no more convoluted logic and building complex business rules - just pure AI bliss. In this blog post, we'll dive into the wonderful world of NGpt and show you how easy it is to use. You might even find a few laughs along the way. The Magic of NGpt NGpt is a transient fault-tolerant .NET 6 OpenAI client that simplifies ChatGPT integration for C# developers. It's like your friendly neighborhood Spider-Man - always there to help you out when you need it most. With just your OpenAI API key, you can start coding AI applications in C# faster than you can say "Peter Parker." Let&

Specflow czyli BDD w praktyce

Dzisiaj pokażę w praktyce w jaki sposób zbieram wymagania korzystając z narzędzia Specflow. Na początku przypomnę nasze historie użtkownika. Potem skonfigurujemy dodatek Specflow Visual Studio. Na końcu pokażę jak wygląda język Gherkin i zaimplementujemy pierwszą historię użytkownika US1. Oto lista funkcjonalności, które będę implementował w aplikacji Perfect Life: US1: Jako użytkownik aplikacji mobilnej chcę ekran logowania aby mieć możliwość zapisywania swoich postępów US2: Jako użytkownik aplikacji mobilnej chcę mieć kalkulator wskaźnika BMI aby móc mierzyć poziom swojej kondycji US3: Jako użytkownik aplikacji mobilnej chcę widzieć wykresy aby móc wizualnie interpretować swoje postępy US4: Jako użytkownik aplikacji mobilnej chcę mieć możliwość rozwiązania quizu, żeby zbadać wskaźnik Body Age US5: Jako użytkownik aplikacji mobilnej chcę pobierać pliki PDF aby mieć dostęp do planów dietetycznych US6: Jako administrator aplikacji chcę zapisywać dane telemetryczne aby móc an

How to call webAPI service in Xamarin?

In the last few weeks I worked on the web service written in ASP.NET Core. I had a plan to connect the Xamarin application to this web service. Today I'll show you how you can connect your Xamarin app to web service located anywhere in the cloud. First we need to have a web service deployed, which is our server-side part of the system. I describe how to create a web service in ASP.NET COre in my previous post: . Today I'll demonstrate how it works from client perspective, in our case it's Xamarin.Forms application but web application or desktop application can use exactly the same code. This is the great benefit of using C# language - we can use the same code on multiple platforms. OK, I bet you're interested in the code. Let's jump to the code. This is the final version of the client class that I can use to save and retrieve data from web service: The class design is straightforward. It has 2 public methods which encapsulate 2 functionalities: adding s