首页 > 解决方案 > Docker 容器连接到 MSSQL:昨天工作

问题描述

我是 docker 新手,很困惑。昨天,我设置了一个 MSSQL docker 映像并且它正在运行。的一些输出docker ps -a

IMAGE: mcr.microsoft.com/mssql/server CREATED: 25 hours ago 
STATUS: Up 25 hours  PORTS: 0.0.0.0:1433->1433/tcp

我正在尝试远程连接以运行脚本。昨天我能够

sqlcmd -S <myIP>,1433 -U SA -P "<myPassword>" -i ./sql-scripts/all.sql -o "out.txt"

但是今天当我运行相同的命令时,我得到了

Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : TCP Provider: No connection could be made because the target machine actively refused it.
.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..

有谁知道今天和昨天之间会发生什么变化来实现这一点?使用 windows 10 企业版、docker for windows、TSQL。我还尝试了https://canyouseeme.org/并确认我的 IP 上未打开端口 1433。

编辑:我可能应该注意到我仍然能够访问sqlcmd容器内部的 repl docker exec -it mySecondServer "bash",然后再进入容器/opt/mssql-tools/bin/sqlcmd -S localhost -U SA内部。

编辑2:今天发生了同样的错误,当我尝试重新启动我的docker容器时(仍然不是我想要的解决方案)我得到了

Error response from daemon: driver failed programming external connectivity on endpoint mySecondServer (9d...): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:1433:tcp:172.17.0.2:1433: input/output error
Error: failed to start containers: 85...

标签: dockertcpdocker-for-windows

解决方案


推荐阅读