Visual Studio 2019 Linux Docker 容器无法访问 SQL 服务器(在网络上)
Visual Studio 2019 Linux Docker Container Cannot Access SQL Server (on Network)
我在 Linux 的 Docker 中使用了 ASP.NET 核心 Web API 应用程序 运行 的模板。
它似乎 运行 正常,直到它需要访问我的 Sql 服务器(运行 在我的网络上)。当它尝试这样做时,出现以下错误:
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: 35 - An internal exception was caught)
内部异常说:
No such device or address
我读到 运行ning docker 使用此命令:--net=host
可以让您的容器访问您的网络。但我似乎无法找到使 Visual Studio 集成工作的方法(按 F5 或 > Docker
工具栏按钮开始 运行 调试)。
如何让 Visual Studio、Docker 和 Linux 联网?
原来这是我的连接字符串。当 windows 和 IIS Express 上的 运行 时,我可以将服务器名称放在我的连接字符串中。
当 运行 在 Linux 容器上时,我需要服务器名称的完全限定域名 (fqdn)。
一旦我这样做了,效果很好。
我在 Linux 的 Docker 中使用了 ASP.NET 核心 Web API 应用程序 运行 的模板。
它似乎 运行 正常,直到它需要访问我的 Sql 服务器(运行 在我的网络上)。当它尝试这样做时,出现以下错误:
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: 35 - An internal exception was caught)
内部异常说:
No such device or address
我读到 运行ning docker 使用此命令:--net=host
可以让您的容器访问您的网络。但我似乎无法找到使 Visual Studio 集成工作的方法(按 F5 或 > Docker
工具栏按钮开始 运行 调试)。
如何让 Visual Studio、Docker 和 Linux 联网?
原来这是我的连接字符串。当 windows 和 IIS Express 上的 运行 时,我可以将服务器名称放在我的连接字符串中。
当 运行 在 Linux 容器上时,我需要服务器名称的完全限定域名 (fqdn)。
一旦我这样做了,效果很好。