I have just started working on a new project, and the Microsoft SQL Server is being used for the project. But I am using Mac as my primary development machine at this moment, and I don’t want to switch to windows now, just for using the SQL server.
Docker is here to rescue.
SQL Server image is available in the docker hub; you can check the docker image details at https://hub.docker.com/_/microsoft-mssql-server.
After finding the SQL Server docker image, the second concern was, which GUI client to use for accessing SQL Server, as SQL Server Management Studio(SSMS) does not work on mac. After researching for a few minutes, I have found the easiest option. Azure Data Studio will solve my problem here.
Here is the easiest config and process that you can use for SQL Server on Docker and Azure Data Studio.
SQL Server docker config
Here is the docker-compose.yml file for SQL Server.
version: "3.9" services: sqlserver: image: "mcr.microsoft.com/mssql/server" environment: SA_PASSWORD: "some2Complex7Password" ACCEPT_EULA: "Y" ports: - "1433:1433"
I have kept the configuration as simple as possible. If you want to use any specific version of SQL Server, check the available options from https://hub.docker.com/_/microsoft-mssql-server.
In the configuration, set the password in the environment value SA_PASSWORD and in the ports section, you can set the port you want to expose the service to. I have kept the default port 1433.
Run your Docker container and then config Azure data studio following the instructions below.
Azure data studio configuration
Download Azure data studio from https://docs.microsoft.com/en-us/sql/azure-data-studio/download-azure-data-studio?view=sql-server-ver15 . Go to add a new connection, and you will see a form like below.
- Connection type: Select “Microsoft SQL Server” from the dropdown.
- Server: enter “localhost,1433” in the field. Make sure to enter the port which you have in the docker configuration.
- Authentication type: Select “SQL login” from the dropdown.
- User name: enter “sa” in the field as the user name.
- Password: enter the password that you set in the docker config file. In my case, it is some2Complex7Password.
- Remember Password: check this checkbox.
NOTE: There is a comma(‘,’) between the localhost and the port number. So use a comma(‘,’) there, do not use a colon(‘:’).
I have kept all other fields to the default value.
Click on Connect button, and you should be connected to the SQL server. You should see a screen like the below.
Azure data studio does not have all the options of SQL Server Management Studio(SSMS), but it will get the job done.
That’s it, done.