SQL server for Linux in Docker

Docker settings

After installing Docker change the memory settings to a value above 3200mb. This is one of the prequisites for installing SQL server for Linux.

Docker memory settings

Kitematic 

Use kitematic to find and install the SQL-server for linux docker image. You will find Kitematic in the menu when u rigtclick on the docker icon in the icon tray:

Docker and Kitematic

In Kitematic search for the SQL-server for Linux image. Make sure you use the image provided by Microsoft. After downloading the image add you will need to add some environment variables. One of them is the SA password. Without this you cannot build a connection. There are two options to specify the environment variables and one of them is simply add them to Kitematic:

Kitematic environment variables

Of course it's allso possible to start the image directly with the necessary environment variables from powershell:

docker run --memory 4096m -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourStrong!Passw0rd>" -p 1433:1433 -d microsoft/mssql-server-linux

Create database in the docker image

After starting the docker image you can connect to SQL-server by specify the ip-addres of the host running docker. In the environment variables you have specified that port 1433 is passed throug docker so just specify the host is enough to connect. Before you can do some test you need to have a database. There are several ways to create a database but one of them is to use the sqlcmd tool wich is included in the latest SQL server for Linux version. Because that is included and nothing needs to be installed I using the sqlcmd tool.

First start a powershell with docker support. In this powershell you can execute the sqlcmd but you will notice that default the linux container cannot find the sqlcmd tool. Therefor you can use this litle hack; add the sqlcmd path to the environment variables for Bash shell.

echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc

Now you can start the sqlcommand tool for creating the database:

:/opt/mssql-tools/bin# sqlcmd -s 192.168.2.6 -U SA -P 'yoursapassword'

Now you will get the sqlcommand tool and can create a database

use master
go
create database LinuxTestDatabase
go

Finally

Now you have a Linux container running with SQL server for Linux. There is no problem with connecting over the het network to this server and database from within VisualStudio 2017. But when I try to add some tables from within Visual Studio 2017 there is a incompatible error:VS2017 incompatible SQL Server version ( SQL server for Linux )

That's to bad now I still have to install SQL Server Manager in order to try to connect to the server and manually create some tables. Something I did try to prevent by using the sqlcmd tools.

{{opmerking.Naam}}:

{{opmerking.OpmerkingText}}

            

Saving your comment....

Naam is verplicht!
Email is verplicht!
Opmerking is verplicht!