Ban*_*ona 3 migration port containers entity-framework-core docker-compose
我在容器上运行 Sql Server。我已经设置了 docker-compose 并且所有服务都能够连接到数据库以执行设计时实体框架核心迁移。
我想从主机连接到数据库。这似乎不适用于以下代码(使用“端口”)。我得到
"
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 53)
The network path was not found
"
Run Code Online (Sandbox Code Playgroud)
docker-compose yaml 文件:
version: '3.4'
services:
mssql:
image: mcr.microsoft.com/mssql/server:2017-latest
container_name: sqlservice
ports:
- 1433:1433
etc...
Run Code Online (Sandbox Code Playgroud)
任何想法都非常感谢。
谢谢 paulsm4
ms 文档的链接给出了答案:
解答:使用本地机器的IP地址见https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker?view=sql-server-2017
查找托管容器的机器的 IP 地址。在 Linux 上,使用 ifconfig 或 ip addr。在 Windows 上,使用 ipconfig。
运行 sqlcmd 指定 IP 地址和映射到容器中端口 1433 的端口。在此示例中,这是主机上的相同端口 1433。如果您在主机上指定了不同的映射端口,您将使用它
(我使用的是 0.0.0.0,还尝试了 docker inspect 给出的 IP 地址 - 这两个都失败了)
| 归档时间: |
|
| 查看次数: |
4410 次 |
| 最近记录: |