SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for ASP.Net, SQL Server, Reporting Services, T-SQL, Windows, AWS, SAP HANA and ABAP


Install and Run SQL Server 2019 on MacOS using Docker Container

In this guide I want to share tips on how to install Microsoft SQL Server 2019 database application using Docker container on a Mac OS. Then SQL developers and database administrators can use Azure Data Studio after they download it and install it, to connect to MSSQL database which is provided by the Docker container.

If you are an addictive user of Mac for your developments, you might already know that Microsoft has released a Linux distribution of Miscrosoft SQL Server data platform. If you do not like to switch to a Windows OS running development computer for your application developments requiring a database management platform like Microsoft SQL Server, then you can think of completing your application development on a MacOS which is running MSSQL by using a Docker image which includes SQL Server 2019, the most recent release of SQL Server data platform.

You can refer to given tutorial to download SQL Server 2019. SQL developers and administrators can use the SQL Server which can be downloaded from the referenced link for trial and development purposes on various operating system platforms.

If you wish to access Microsoft SQL Server Linux for Docker Engine image directly, please visit hub.docker.com.


Afterwards in this SQL tutorial, I want to share with programmers the steps that I followed to install SQL Server 2019 on my Mac computer using docker image


Installing Docker for Mac OS

The first thing SQL developers should do is installing the Docker Desktop app on Mac OS.
The installation steps are well described at docs.docker.com web portal.
In fact, all you will do is downloading the application provided by Docker Desktop for Mac link and following the setup steps.

If you are not yet a member of docker.com, you are required to register for this free web site.
If you are already a member, you can login with your Docker ID and continue.
Later you are able to download a runnable .dmg MacOS image fil of Docker Desktop for Mac.
Double click on the Docker.dmg file then drag the Docker.app application icon to Applications folder. Now you can run the Docker app on your Mac computer.

The first thing, you should do after you run the Docker application is configure it for being able to run SQL Server via a docker container. Since SQL Server requires a significant amount of resources, this step is highly recommended.
On the top of your Mac screen, click ın the Docker icon and follow the menu option "Preferences...". There you will be able to adjust the amount of RAM for your docker container to host SQL Server 2019 on it.
In Advanced tab "Memory" amount can be adjusted to a suitable amount according to your Mac capacity, 4 or better 6 GB RAM can help you to run SQL Server 2019 image with a reasonable performance using docker container.

At last, we can continue with the next step where you will download the image file including SQL Server 2019 data platform server and launch it.


Download SQL Server 2019 Docker Image

SQL developers can find the SQL Server image of the specific version that they want to run, on the web portal Docker Hub that I have shared previously in this tutorial, at page Microsoft SQL Server

I downloaded and installed the latest version of MSSQL Server which is the latest release of SQL Server 2019
And this corresponds to the docker image named mcr.microsoft.com/mssql/server:2019-latest.

After you decide and select the SQL Server Docker Image that you want to install on your Mac, you can launch a new Terminal screen on your Mac.
You can launch the Terminal application among the Applications installed on your MacOS.

Execute the docker pull mcr.microsoft.com/mssql/server:2019-latest command on the Terminal screen as seen in below.

download docker image of SQL Server 2019 latest release

SQL Server 2019 image will be downloaded in parts from Docker Hub using the "Docker Pull" command. This download will take some time.

Eralper-MacBook-Pro:~ eralper$ docker pull mcr.microsoft.com/mssql/server:2019-latest
2019-latest: Pulling from mssql/server
59ab41dd721a: Pull complete
57da90bec92c: Pull complete
06fe57530625: Pull complete
5a6315cba1ff: Pull complete
739f58768b3f: Pull complete
b77fc38faae9: Pull complete
11ca25075c70: Pull complete
c957a137b2c5: Pull complete
4794f7ad490c: Pull complete
Digest: sha256:0753f9e9c614c469e1e6b98ea60b21e20abd249323c9f6a9eab476c87a8cf826
Status: Downloaded newer image for mcr.microsoft.com/mssql/server:2019-latest
mcr.microsoft.com/mssql/server:2019-latest
Eralper-MacBook-Pro:~ eralper$
Code

After the SQL Server 2019 docker image download is completed, the docker image can be launched within a new "Docker Container" by executing the docker command in the format shared below on the Terminal screen.

Before, executing the command, let's go over the arguments of the docker command.
One of the important parameters is SA_PASSWORD which is the password of the System Admin or sa user. SQL developers should choose a strong password for the "sa" system administrator user. The selected password will be required frequently later in this tutorial and during your work with the SQL Server installed. Do not forget the "sa" user password when running the docker container.

Port number 1433 is the default port for connecting to SQL Server. In following command it is identified bby using -p parameter.

Another important parameter is the "name" parameter. This will be the name of the SQL Server 2019 docker container which we will be launching with the command. If you run a huge number of docker containers on your Mac OS, the naming you are using will help you a lot to do your work with ease.

Maybe the most important argument of the "Run" command is the name of the docker image which we will download and install from SQL Server Docker Hub web address. For this tutorial, for the latest release of SQL Server 2019, the name of the docker image is mcr.microsoft.com/mssql/server:2019-latest

If you want to learn all the parameters of Docker Run command, please refer to the given tutorial.

sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Eralper@6" -p 1433:1433 --name sqlserver2019 -d mcr.microsoft.com/mssql/server:2019-latest
Code

If the "docker run" command is successfully executed, when following "docker" command is executed the "container" status will be "Up" in the output result list.

sudo docker ps -a
Code

docker container list

One can list the docker containers using the docker ps (ps for process status) command.
This command displays the Container ID, Image (docker image used), Created (create date), Status, Ports, Names, etc information about the docker containers created on that Mac OS

Now, we have a running Docker Container which runs a SQL Server instance on our Mac.
It is time to connect to SQL Server 2019 instance and execute SQL queries and SQL commands on databases.


Execute Query via SQLCMD on SQL Server 2019 Database

If SQL developer runs following code on Terminal application, it will enable the developer to call a script on the Docker Container named "sqlserver2019"

sudo docker exec -it sqlserver2019 "bash"
Code

By executing the below sqlcmd script we can connect to the SQL Server default instance by providing the "sa" user and password.

/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "Eralper@6"
Code

When the SQLCMD command line is active, a SQL developer can now execute Transact-SQL scripts on SQL Server 2019 database and query SQL data.
For example, as one of the the most simple query samples, I will display the version of the database instance which we are working on currently by displaying the @@version system parameter.
"GO" command executes the SQL query written up to that line.

SELECT @@version
go
Code

The output of the above SQL query is seen in below screenshot.

connect docker container to execute SQLCmd query

In fact, I don't believe the SQLCMD interface is a good environment for developing SQL code. If you prefer to install a SQL Server client application on your Mac OS, this will help you complete your SQL developments on SQL Server 2019 databases easier in a shorter time.

Note: To exit/quit from SQLCMD command line, you can use "Control + C" key combination


Install Azure Data Studio on MacOS

If you install and run SQL Server 2019 docker container on your Mac computer using Docker, to interact with the SQL Server instance the easiest and comfortable method is to use a SQL Server client tool.

Azure Data Studio for macOS is a SQL client tool developed by Microsoft which is similar to SQL Server Management Studio for your Mac

You can download MacOS for Azure Data Studio from this link.

After you complete the download, double click on the zipped or compressed file and drag the Azure Data Studio.app file to Applications folder. Now among Applications you can see Azure Data Studio too.

After you launch Azure Data Studio, SQL developers can create a connection to the SQL Server instance running on the docker container as seen below.

connection to SQL Server from Azure Data Studio

After the connection is validated using test connection, the SQL queries and SQL Server application codes can be developed on the GUI provided by Azure Data Studio.



SQL Server

SQL Server 2019 Installation
download SQL Server 2019
download SQL Server 2017
download SQL Server 2016
download SQL Server 2014
download SQL Server 2012
MacOS ve SQL Server 2019


Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.