Docker for SQL Server on Mac

Docker eliminates the need to install VirtualBox, Parallels Desktop or Bootcamp running Windows OS on a Mac. It enables us to run software across different computer systems without encountering configuration issues. The software runs in its own isolated environment, and all configuration settings are baked in the container.

An overview of how Docker works and installation guide is here  https://www.docker.com/products/docker-hub/

Once you have installed Docker, check Docker’s GB allocation. SQL Server requires at least 3.25GB to run.

To do this:

  1. Select Preferences from the small Docker icon menu in the top

  2. Select Advanced

  3. Slide the memory slider up to 4GB

  4. Click Apply & Restart

SQL Server installation

1. Pull the SQL Server Image. Open Terminal and run the following command:

sudo docker pull mcr.microsoft.com/mssql/server:2019-latest

2. Launch the image you downloaded in Docker

docker run -d --name example_sql_server -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Strong.Pwd-123' -p 1433:1433 mcr.microsoft.com/mssql/server:2019-latest

 Below explains the command above:

-d

Launches the docker container allowing it to run in the background without a terminal window open.

--name

Sets a name for the Docker container. In this example, we are using example_sql_server.

-e 'ACCEPT_EULA=Y'

Confirms you agree with the EULA (End User License Agreement) for Docker.

-e 'SA_PASSWORD=Strong.Pwd-123'

Sets the database password. In this example, we are using "Strong.Pwd-123" as the password.

-p 1433:1433

Maps the container to the local port 1433.

mcr.microsoft.com/mssql/server:2019-latest

Selects an image file for Docker to use.

3. Check Docker container with this command:

docker ps

*If the STATUS output column states Up, the container is running. If EXITED, container is not running and requires troubleshooting.

4. Install SQL Server Command-Line Tool if you prefer CLI.

sudo npm install -g sql-cli

*This allows you to run commands and queries for an SQL Server instance in Terminal. Installing this cli with NPM requires that you have Node.js already installed. Follow this link for more information - Homebrew

5. Azure Data Studio is a bit more user friendly for those who are not comfortable with CLI.

Download and install Azure Data Studio

6 .Launch Azure Data Studio and Connect to SQL Server.
*Make sure the Docker container is running in your Docker hub.

Server Name: localhost
Authentication Type: SQL Login
User name: sa
Password: myPassw0rd
Database Name: <default>
Server Group: <default>

 

 

 

 

 

 

 

Back to Blog