Ensure you have docker setup on your machine. Follow this link to setup docker on your machine docs.
Pull the MSSQL ubuntu image from the docker hub.
1sudo docker pull mcr.microsoft.com/mssql/server:2019-CU3-ubuntu-18.04
After that then enter the following command
1sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourStrong@Passw0rd>" \2 -p 1433:1433 --name sql1 \3 -d mcr.microsoft.com/mssql/server:2019-CU3-ubuntu-18.04
Ensure you replace
<YourStrong@Passw0rd> with your password
-p indicates your port —name specifies the name of your container
Run the command below to view all containers currently running on your machine.
sudo docker ps -a
The GUI tool we’ll be using is Azure Data Studio
Follow the link and download the azure data studio.
currently, these are our details. Password: This is what we declared in SA_PASSWORD as earlier.
Username: this value is
sa Server: localhost
Then fill out these details in Azure data studio.
Lastly, since we might want to create a new database in the azure data studio
Enter the following in the
new Query section of the dashboard.
1IF NOT EXISTS (2 SELECT name3 FROM sys.databases4 WHERE name = N'DemoDB'5)6CREATE DATABASE [DemoDB]7GO
The above command creates a database called DemoDB. you can the connect to this database and run various actions like migrations or create tables manually.
To connect to the DemoDB database we created, below is a typical connection string.
1String connectionString = @"2 Server=127.0.0.1;3 Database=DemoDB;4 User Id=sa;5 Password=yourPassword6 ";