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

Connect to Azure from command line on Windows

When working with Azure we could go two ways: 1) using Azure portal and work in UI from your web browser 2) Connect to Azure from command line and run commands by typing in text in CMD. I already wrote about option 1 but today I'll show you how to start with option 2 which is Command line. First we need to download MSI installer from Microsoft website After sucessfull instalation you're ready to test az command. Open CMD and type in 'az' Now let's log in with your Azure credentials. Just type in "az login" in cmd. You should be redirected from command line to web browser and prompted for username and account in web browser. When you confirm your identity you'll be presented the screen like this in command line:

Learning e24cloud.com API

Today I'll show you how to use API in order to create virtual server in the cloud directly from your code. We're going write a script in PHP language and use Amazon SDK API to connect with e24cloud.com, which is the biggest and most modern hosting provider in Poland. First we need to install Amazon SDK http://docs.aws.amazon.com/aws-sdk-php/v3/guide/getting-started/installation.html One important note: We can use the latest version of amazon SDK but we also need to do one trick. We'll use signatureV2 instead ov Signaturev4 as e24cloud doesn't support SitnatureV4 yet. You can download it here: https://github.com/aws/aws-sdk-php-v3-bridge We need to download SDK and the bridge which allows us to use Signaturev2 to the same folder, so that require instruction work seamlessly in the form that I provided in the example below. Then go to your admin panel in e24cloud.com to find two values: a key and a secret. In the following code you need to paste those 2 values. ...

Up and running with Laravel

Today I'll show you how to start working with Laravel - a modern PHP framework. After reading this article you'll be able to: - Install XAMPP - Configure Virtual Hosts on Apache - Create your first application in Laravel - Run the application - Start coding As a first step I encourage you to visit Laravel.com to get some background knowledge about Laravel. Laravel is a PHP framework which is build on top of the MVC pattern (MVC stands for Model View Controller). You can find general explanation of MVC design pattern with some code examples written in Java here . I assume that you've already installed XAMPP which has version for Linux, Windows and OS X. Personally I'm using Windows in this tutorial but on each operating system it should work similarly. You can get the installer of XAMPP from this page: https://www.apachefriends.org/pl/index.html. When installer prompts you which options you want to install, you need to select Apache and you are free to...