使用host.docker.internal从Docker连接到本地计算机(主机)中的SQL Server [英] Connect to SQL Server in local machine (host) from docker using host.docker.internal

查看:2467
本文介绍了使用host.docker.internal从Docker连接到本地计算机(主机)中的SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用 host.docker.internal 连接到在本地计算机上运行的SQL Server实例(如

解决方案

如果有人遇到类似的问题,这就是我的解决方法




  • 打开SQL Server配置管理器

  • 在服务器网络配置中启用TCP / IP

  • 重新启动SQL服务服务





如果仍然无法正常工作,还需要检查一些东西


  1. 防火墙(开放端口1433)

  2. 启用与SQL Server的远程连接


I'm trying to connect to my SQL Server instance running in my local computer using host.docker.internal (as recommended in https://docs.docker.com/docker-for-windows/networking/#use-cases-and-workarounds)

The host.docker.internal is successfully resolved to an IP, and it's ping-able

And I've opened up the port 1433 in my firewall configuration

Error message

Connection refused 192.168.65.2:1433

My connection string

Data Source=host.docker.internal,1433;Initial Catalog=;Persist Security Info=False;User ID=;Password=;MultipleActiveResultSets=True;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;

docker version

Client:
 Version:      18.03.1-ce
 API version:  1.37
 Go version:   go1.9.5
 Git commit:   9ee9f40
 Built:        Thu Apr 26 07:12:48 2018
 OS/Arch:      windows/amd64
 Experimental: false
 Orchestrator: swarm

Server:
 Engine:
  Version:      18.03.1-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.5
  Git commit:   9ee9f40
  Built:        Thu Apr 26 07:22:38 2018
  OS/Arch:      linux/amd64
  Experimental: true

Docker for windows version

解决方案

If anyone have similar problem, here's how I solve it

  • Open SQL Server Configuration Manager
  • Enable TCP/IP in Server Network Configuration
  • Restart SQL Service Service

If it's still not working, there are a few more things to check

  1. Firewall (open port 1433)
  2. Enable remote connections to your sql server

这篇关于使用host.docker.internal从Docker连接到本地计算机(主机)中的SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆