简体   繁体   中英

How to connect to SQL Server hosted on Docker in Azure Ubuntu VM

I have installed SQL Server 2019 docker on Azure Ubuntu VM. The container is up and running. However, I cannot connect to it using SSMS from outside the VM. While running the container I used port 1450 to map to 1433. Also, I have configured the NSG to allow the traffic. Still, I have no luck.

在此输入图像描述

在此输入图像描述

iptables -L 在此输入图像描述

NSG 在此输入图像描述

Thanks

To run SQL Server through Docker on Ubuntu, you can follow the steps here:

  1. Pull the docker image to your Ubuntu host:

    docker pull mcr.microsoft.com/mssql/server:2019-CTP2.2-ubuntu

  2. run the image through the docker command:

    docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=azureUser@2018' -p 1450:1433 -d --name mssql mcr.microsoft.com/mssql/server:2019-CTP2.2-ubuntu

  3. check the container if it runs well, you do this through the docker command:

    sudo docker exec -it mssql /opt/mssql-tools/bin/sqlcmd \\ -S localhost -U SA -P '<YourStrong!Passw0rd>'

  4. open the port 1450 in the NSG associated with your VM

  5. connect the SQL Server through the SSMS like this: 在此输入图像描述

Note: If you open the firewall in the Ubuntu VM, you also need to open the port in the firewall.

You can find the Docker image information in Microsoft SQL Server and more details about Run && Connect the SQL Server image with Docker .

Update:

When you check the NSG rules, I suggest you can go into the VM networking, it will show all the NSGs that associated with the subnet and NIC. If allow port, you should add the rule to both NSG or change the NSG as the same, then you can just add the rule to only one NSG. Check the NSG rule as below:

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM