Run MSSQL Server in your MAC/Windows with Docker

As a developer or DevOps resource, you might have had a requirement of running an RDBMS database such as mssql server in your local machine (Windows/Mac)

In this post, we are going to cover, how to install and run MSSQL server as a Docker container in 5 easy steps.

Steps to run MSSQL server in your localhost

  1. Install Docker desktop in your local machine (windows/mac)
  2. Validate if Docker Container Engine is running
  3. Run the MSSQL container using docker run command
  4. Check if the container is running with docker ps command
  5. Connect to the database with SQL CLI tools

Step1: Install Docker Desktop in your Local machine

Refer the following link and install Docker CE in your local machine. MAC/Windows

Step2: Validate If Docker CE is running

Open the command prompt (Windows) or terminal (Mac) and type the following command to make sure that the Docker CLI is installed and Docker CE is running

# To check the version
docker – version 

# To check if the Docker Daemon is running and to list the containers
docker ps

You will get a connection error like this if your docker daemon (or) docker desktop is not running

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Step3: Start the Docker MSSQL 2017 Server

Now you have a running Docker Engine on your local system and you can technically run any Docker images.

This is the command you should run in order to start the ms sql server container

docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=SecurePassword123' – name mssql2017 -p 1433:1433 -d

In the previous command, You can update the value of SA_PASSWORD as per your choice

The Docker image gets downloaded if it is not already present. if the image is already available in local, It would just print the container id and start the mssql container.

Here we have named the container as mssql2017 you can change this name as well as per your requirement.

Step4: Check If the container is running

You can validate if the container is running and staying alive by executing the following command

docker ps

You should see your container running with the name you have given in the previous step, in my case it is mssql2017

Step5: Try to Connect to this MSSQL Server using the SQL Client

You can use the following connection properties in your SQL Client Software to test the connection

DB Name: master
UserName: sa
Password: SecurePassword@1 (unless changed by you)
Hostname: localhost
Port: 1433

If you are not already having any SQL Client. I would recommend DBeaver. or if you prefer CLI based SQL client you can use sql-cli

DBeaver is a Single SQL Client for multiple different databases such as MS SQL, Oracle, MySql etc

docker mssql

Create a New Connection in DBeaver and Enter the aforementioned connection details and click on test connection to validate

If you are getting Connected message on the Test Connection. You are Good.

If you are preferring SQL-CLI way. Refer this article or the below Screen clip to know how to use it.

VLOG - Screen record

Refer the following screen record or terminal capture to understand the entire steps better.


Let me know in comments if you need further help or have any questions.

Is there a better way you can think of running MSSQL or ORACLE in your local? Let me know in comments

Sarav AK

Follow me on Linkedin My Profile
Follow DevopsJunction onFacebook orTwitter
For more practical videos and tutorials. Subscribe to our channel

Buy Me a Coffee at

Signup for Exclusive "Subscriber-only" Content