简体   繁体   English

使用 host.docker.internal 从 docker 连接到本地机器(主机)中的 SQL Server

[英]Connect to SQL Server in local machine (host) from docker using host.docker.internal

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 )我正在尝试使用host.docker.internal连接到在本地计算机上运行的 SQL Server 实例(如https://docs.docker.com/docker-for-windows/networking/#use-cases-and 中推荐的那样) -解决方法

The host.docker.internal is successfully resolved to an IP, and it's ping-able host.docker.internal已成功解析为 IP,并且可以 ping 通

And I've opened up the port 1433 in my firewall configuration我在防火墙配置中打开了端口1433

Error message错误信息

Connection refused 192.168.65.2:1433连接被拒绝 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; 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 Docker for windows 版本

适用于 Windows 的 Docker

If anyone have similar problem, here's how I solve it如果有人有类似的问题,这就是我解决它的方法

  • Open SQL Server Configuration Manager打开 SQL Server 配置管理器
  • Enable TCP/IP in Server Network Configuration在服务器网络配置中启用 TCP/IP
  • Restart SQL Service Service重新启动 SQL 服务服务

TCP/IP

If it's still not working, there are a few more things to check如果它仍然无法正常工作,还有一些事情需要检查

  1. Firewall (open port 1433)防火墙(开放端口 1433)
  2. Enable remote connections to your sql server启用与 sql server 的远程连接

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从 windows Z05B6053C415A2134EAD6 容器中的 .NET 应用程序连接到在主机上运行的 SQL 服务器 - How do you connect to SQL Server running on the host from a .NET app in a windows docker container 从Homestead Vagrant连接主机的SQL Server 2017 - Connect host machine's SQL Server 2017 from homestead vagrant 从Docker容器到主机中SQL Server dblocal的连接字符串 - Connectionstring from docker container to SQL Server dblocal in host 无法从同一主机上的Web应用程序Docker访问Docker托管的SQL Server - Can't reach docker-hosted SQL server from web app docker on same host 如何从 Linux Docker 容器连接到本地 SQL Server - How to Connect to Local SQL Server From Linux Docker Container 在Linux Docker映像上运行的应用程序无法连接到本地Windows计算机上的SQL Server - Application running on Linux Docker image, is unable to connect to SQL server on local windows machine 如何从Mac主机连接到Win7虚拟机中的SQL Server? - How to connect to SQL Server in Win7 virtual machine from Mac host? 如何将 Microsoft SQL Server(在 docker 中)容器移动到新主机 - How to move a Microsoft SQL Server (in docker) container to a new host 如何在centos7主机上使用docker-compose .yml将JBoss服务器容器与SQL服务器链接? - how to link a JBoss server container with SQL server one using docker-compose .yml on centos7 host? 使用本地计算机连接到VM中的SQL Server - Connect to SQL Server in VM using local machine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM