我获得了SQL Server Developer版本的docker映像并启动了它:
PS C:\WINDOWS\system32> docker ps -aa
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
81347866fc2b microsoft/mssql-server-windows-developer "powershell -Command…" About an hour ago Up About an hour (healthy) 0.0.0.0:1433->3341/tcp trusting_mccarthy
PS C:\WINDOWS\system32>
如您所见,它正在监听端口3341。 IP为:
PS C:\WINDOWS\system32> docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 8
172.17.234.173
但是我无法从主机连接到它:
PS C:\WINDOWS\system32> sqlcmd -S 172.17.234.173,3341
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : TCP Provider: An attempt was made to access a socket in a way forbidden by its access permissions.
.
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..
必须做错了什么。有什么提示吗?
PS:我也无法连接到1433:
PS P:\> sqlcmd -S 172.17.234.173,1433
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : TCP Provider: An attempt was made to access a socket in a way forbidden by its access permissions.
.
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..
PS P:\>
使用的Docker Run命令:
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourStrong!Passw0rd>" `
-p 1433:1433 --name sql1 `
-d mcr.microsoft.com/mssql-server-windows-developer
note 我也从1433:3341开始。两种方式都不开心