Visual Studio For Mac Sql Server

Docker, SQL Server

November 6, 2017 - Docker, SQL Server

First step is to use SQL Server Management Studio to generate scripts from an existing database. Use the mssql Visual Studio Code extension to connect and manage your database! Microsoft's documentation: Run the SQL Server Docker image on Linux, Mac, or Windows. Share: Twitter Facebook LinkedIn. About David Neal.

Install and Run SQL Server Docker Container on Mac

Like most people, I use Mac , Windows as well Linux OS for development and testing purposes. Primarily I use Mac for Development purpose. I have few projects which uses SQL Server as Data Storage Layer. Setting up Docker Container on Mac and Opening up the ports was pretty easy and doesn’t take more than 10 Minutes.

Steps followed :
  • Install Docker
  • Pull SQL Server Docker Image
  • Run SQL Server Docker Image
  • Install mssql Client
  • Install Kitematic
  • Open the Ports to connect to SQL Server from the network
  • Setup port forwarding to enable access outside the network
Install Docker :

Get Docker dmg image and install. Just follow the prompts and its very straight forward.
https://docs.docker.com/docker-for-mac/install/#download-docker-for-machttps://download.docker.com/mac/stable/Docker.dmg

Visual Studio For Mac Download

Once you have installed docker , you can verify the installation and version.

Docker Version
docker pull microsoft/mssql-server-linux:2017-latest
Create SQL Server Container from the Image and Expose it on port 1433 ( Default Port )
Create macsqlserver Container from Linux SQL Server Image
2
4
ruby-e'$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)'
node-v
Install SQL Client for Mac
2
4
6
Connecting tolocalhost...done
sql-cli version0.6.2
mssql>select *from sys.dm_exec_connections
Get External Tools to Manage Docker

Kitematic

Open Up the Firewall to connect to SQL Server from outside the Host

Visual Studio

Ensure your firewall is configured to allow the connections to the SQL Server. I turned of “Block all incoming connections” and enabled “Automatically allow downloaded signed software to receive incoming connections”. Without proper firewall configurations, you won’t be able to connect to the SQL Server outside the host.

Ensure Firewall allows the incoming connections to the Docker

Connecting from the Internet ( Port forwarding Setup )

Lets say you want to connect to the SQL Server you setup from outside the network or from anywhere via internet,you can setup port forwarding.

Get your public facing IP and setup the port forwarding for Port 1433 ( SQL Server port you have setup your docker container ). If its setup correctly , you should be able to telnet into that port to verify the connectivity.

Telent to verify the SQL Server is accessible for Internet

Unless you absolutely require it , its very bad idea to expose the SQL Server to internet. It should be behind the network , only your webserver should be accessible via internet.

Troubleshooting :

While launching docker container , if you get the error saying that it doesn’t have enough memory to launch SQL Server Container, go ahead and modify the memory allocation for docker container.

  • This image requires Docker Engine 1.8+ in any of their supported platforms.
  • At least 3.25 GB of RAM. Make sure to assign enough memory to the Docker VM if you’re running on Docker for Mac or Windows.

I have setup this way.

Docker Memory configs

If you don’t provision enough memory, you will error like this.

Look into Docker logs

Following command ( docker ps -a and docker logs mcsqlserver ) shows list of running processes and docker logs.

Microsoft Visual Studio For Mac