Docker with MSSQL

This article talk about how to setup MSSQL in docker run on MacOS.

Pull images

In this example, I’ll choose SQL Server 2017 Docker Image

sudo docker pull

Optionally, you can choose SQL Server 2019 Preview Docker Image

sudo docker pull

Verify your pulled image

Run container

Once finish pull the images, we need to start the container

docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=initi@L@pass" -p 1433:1433 --name tutorial -d

Password must be at least 8 characters long, contains upper and lower case, number and symbols. You specific the password within the diamond symbol <password>

  • set environment -e
  • port mapping -p
  • naming container –name
  • run in background -d
  • container images,

Verify your container

docker ps

Change SA Password

1 more step to go before we can connect via GUI tools, . We need to change the SA password and this can be done via docker exec to run sqlcmd.

You can use this password generator

docker exec -it tutorial /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "initi@L@pass" -Q 'ALTER LOGIN SA WITH PASSWORD="Z@Q69ZdFH"'

Test Connection

Launch a interactive container to connect the MSSQL server

docker exec -it tutorial "bash" 
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "Z@Q69ZdFH"
1> SELECT Name from sys.Databases
2> GO

Database UI Client

There are quite numbers of tools that you can use to connect to your docker’s MSSQL container.


Download from the website or search it from the AppStore.


  1. Obtain the host ip address ipconfig getifaddr en0 Example:
  2. Enter the port 1433
  3. Enter the Login: SA
  4. Enter the password: Z@Q69ZdFH

Docker with MSSQL

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.