Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect Docker with Azure Data Studio?

I install docker container on mac(OS X) and install Microsoft SQL 2017 image file on docker.So, I try to connect docker with Azure Data Studio but didn't connect it. Can I connect docker with Azure Data Studio and How to configure it? Please help me, thank a lot.

like image 580
Jonzz Avatar asked Nov 05 '18 08:11

Jonzz


People also ask

How do I access Docker in SQL Server?

Identify the Docker tag for the release you want to use. To view the available tags, see the mssql-server-linux Docker hub page. Pull the SQL Server container image with the tag. For example, to pull the 2019-CU15-ubuntu-20.04 image, replace <image_tag> in the following command with 2019-CU15-ubuntu-20.04 .

How do I know if SQL Server is running Docker?

You can look at the SQL Server setup and error logs in /var/opt/mssql/log. If the container isn't running, first start the container. Then use an interactive command-prompt to inspect the logs. You can get the container ID by running the command docker ps .


2 Answers

Use 127.0.0.1,1433 instead of 127.0.0.1:1433

This syntax is what my ASP.NET Core app uses as syntax so I figured MS liked that format for connection strings and such.

This worked for me. Hope it helps.

like image 131
Gary Krause Avatar answered Oct 03 '22 09:10

Gary Krause


I was able to run SQL server on MAC using Docker by running it along with the Azure Data Studio.

In order to connect to a server, you need to go to preferences of your Docker settings and increase the Memory allocation from the default of 2GB to minimum 4GB (as SQL server needs min 3.25GB space). Save and restart the docker.

Once restarted, all you need to do is pull the docker image of the sql server and download it. this can be done by below commands on your terminal . FYI, I am using bash commands below:

Command 1:

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

This will pull the latest vesion docker image and download. Once done, you need to set your SQL authentication on the server for your database. Follow below commands:

Command 2:

   sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<SetYourPasswordHere>' \
   -p 1433:1433 --name sql1 \
   -d mcr.microsoft.com/mssql/server:2017-latest

This sets your password and uses the port 1433 for SQL server (which is the default port). To confirm if the image has been created and the SQL server is running on docker, execute the below command to check log(s).

Command 3:

docker ps

To check all instances in your history of dockers( i.e. if you already had dockers installed before you are attempting this SQL connection/execution), run the below command and it will give you all the logs of all instances you have created

Command 4:

docker ps -a 

or

docker ps -all

Once, you have completed above steps and see that the docker has created SQL instance, you need to go to Azure Data Studio and set the below credentials to access the server that you just created above using Docker.

Server: localhost
Authentication Type: SQL Authentication
Username: sa
Password: <Check Command 2 to see what you entered in the password where it says SetYourPasswordHere>

Hope this helps in your tryst with running SQL server on your MAC. All the Best!

like image 23
Anchit Avatar answered Oct 03 '22 10:10

Anchit