编排:
bridge
)网络上运行。起初,我只是将连接字符串保留为.,1444
,但意识到容器必须在自身之外查找才能获得所需的host本地主机。
到目前为止,我已经尝试过:
127.0.0.1:1444
host.docker.internal:1444
127.0.0.1,1444
host.docker.internal,1444
.,1444
我一直收到此错误:
Connection id "0HLV8EI9HSV9D", Request id "0HLV8EI9HSV9D:00000009": An unhandled exception was thrown by the application.
System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 40 - Could not open a connection to SQL Server)```
最常见的方法是在docker run命令中添加--network="host"
,然后docker容器中的127.0.0.1将指向您的docker主机。
如果这不适合您,this question包含许多破解方法来实现相同的目的。
例如:
我相信该链接将帮助您找到最适合您的解决方案。