SQL Server and SQL Server Management Studio on Mac (and Linux): with Docker and Azure Data Studio
History
In summer and autumn 2017 I've got in touch with (Microsoft) SQL Server and SQL Server Management Studio (SSMS). The, then, actual project required working exclusively on Windows. Fortunately, the world rotated further. Microsoft went more cross platform with the new CEO Satya Nadella.
In autumn 2017 happened:
- Microsoft ported SQL Server 2017 to Linux
In autumn 2018 happened:
- Azure Data Studio, a smaller cross plattform version of SQL Server Management Studio was released.
Now you can have the same experience on Linux like on Windows!
Mac
The situation on Mac looks a bit different. Here you have to use a bridge. Either you use a classic virtualization software like Parallels Desktop or VMware Fusion to create a virtual machine, and install Windows or Linux. Then you install SQL Server (and optionally SSMS), and access it from outside by an IP address and a port.
A more lightweight solution is Docker. Microsoft shows you how to do it. I want to refine their idea.
SQL Server by Docker
Pulling an image with SQL Server
The latest version of an image with SQL Server can by obtained by:
docker pull mcr.microsoft.com/mssql/server
A practical thing is to separate the creation, starting and stopping of a docker container. Therefore I propose a separation instead of a docker run command.
Creation of a Docker container
You create an initial Docker container from the image with the following command.
docker create -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=FooBar' -p 1433:1433 --name sql1 mcr.microsoft.com/mssql/server
Explanation:
- The system administrator of SQL Server is the user SA. I give it the password FooBar.
- The name of the container is sql1.
- The first port in 1433:1433 target port, target_port:1433.
Starting the container
The container is then started with
docker start sql1
Connecting to the database instance
To connected to your database instance with Azure Data Studio, DataGrip (from JetBrains) or Eclipse, you have to provide the data from above:
- Host/server: localhost
- User name: SA
- Password: FooBar
In case of trouble:
- Port: 1433
Shutting down the container
docker stop sql1
Deleting the container
docker rm sql1
Conclusion
Now you have a database more to dive in!
Awesome
Very cool!!