docker server 容器连接sql_从Docker容器连接到SQL Server数据库

在Windows 10环境下,使用Docker容器运行.NET Core应用时,尝试连接到远程SQL Server数据库遇到错误。通过创建SQL Server认证用户,更改服务器认证模式,并在Dockerfile中配置端口暴露,成功解决了从Docker容器连接SQL Server的问题。
摘要由CSDN通过智能技术生成

I have docker for windows installed on my machine. There is a console application targeting .net core 1.0.0 that tries to access a SQL Server database running on a different VM. I can ping the VM running SQL Server from my machine.

When I try to run the console application using dotnet run from the command prompt on my machine it works fine. But when the same application is run inside a docker container I get a message

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)

I tried using

docker run --add-host sqldemo:

but that made no difference.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值