简体   繁体   English

如何连接Azure Ubuntu VM中托管在Docker上的SQL Server

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

I have installed SQL Server 2019 docker on Azure Ubuntu VM. 我在Azure Ubuntu VM上安装了SQL Server 2019 docker。 The container is up and running. 容器已启动并正在运行。 However, I cannot connect to it using SSMS from outside the VM. 但是,我无法使用来自VM外部的SSMS连接到它。 While running the container I used port 1450 to map to 1433. Also, I have configured the NSG to allow the traffic. 在运行容器时,我使用端口1450映射到1433.此外,我已配置NSG以允许流量。 Still, I have no luck. 不过,我没有运气。

在此输入图像描述

在此输入图像描述

iptables -L iptables -L 在此输入图像描述

NSG NSG 在此输入图像描述

Thanks 谢谢

To run SQL Server through Docker on Ubuntu, you can follow the steps here: 要在Ubuntu上通过Docker运行SQL Server,您可以按照以下步骤操作:

  1. Pull the docker image to your Ubuntu host: 将docker镜像拉到Ubuntu主机:

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

  2. run the image through the docker command: 通过docker命令运行映像:

    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: 检查容器是否运行良好,通过docker命令执行此操作:

    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 打开与VM关联的NSG中的端口1450

  5. connect the SQL Server through the SSMS like this: 通过SSMS连接SQL Server,如下所示: 在此输入图像描述

Note: If you open the firewall in the Ubuntu VM, you also need to open the port in the firewall. 注意:如果在Ubuntu VM中打开防火墙,还需要在防火墙中打开端口。

You can find the Docker image information in Microsoft SQL Server and more details about Run && Connect the SQL Server image with Docker . 您可以在Microsoft SQL Server中找到Docker镜像信息,以及有关Run &&使用Docker连接SQL Server镜像的更多详细信息。

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. 当您检查NSG规则时,我建议您进入VM网络,它将显示与子网和NIC关联的所有NSG。 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. 如果允许端口,您应该将规则添加到NSG或将NSG更改为相同,然后您只需将规则添加到一个NSG。 Check the NSG rule as below: 检查NSG规则如下:

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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