This article talk about how to setup MSSQL in docker run on MacOS.
In this example, I’ll choose SQL Server 2017 Docker Image
sudo docker pull mcr.microsoft.com/mssql/server:2017-latest
Optionally, you can choose SQL Server 2019 Preview Docker Image
sudo docker pull mcr.microsoft.com/mssql/server:2019-CTP3.2-ubuntu
Verify your pulled image
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 mcr.microsoft.com/mssql/server:2017-latest
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, mcr.microsoft.com/mssql/server:2017-latest
Verify your container
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.
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"'
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
Database UI Client
There are quite numbers of tools that you can use to connect to your docker’s MSSQL container.
SQLPro For MSSQL
Download from the website or search it from the AppStore.
- Obtain the host ip address ipconfig getifaddr en0 Example:192.168.0.128
- Enter the port 1433
- Enter the Login: SA
- Enter the password: Z@Q69ZdFH