How to Connect to Local SQL Server From Linux Docker Container

…衆ロ難τιáo~ 提交于 2019-12-11 14:44:54

问题


I am trying to connect to my local instance of SQL Server using a linux Docker container running on my Windows machine. I can connect successfully using Data Source=localhost when running under Windows. I've discovered that localhost is not supported in a connection string on linux, so here is what I've also tried and failed with:

  • Data Source=localhost
  • Data Source=localhost,1433
  • Data Source=127.0.0.1
  • Data Source=127.0.0.1,1433
  • Data Source=127.0.0.11
  • Data Source=127.0.0.11,1433
  • Data Source=172.23.0.1 - My local IP Address
  • Data Source=172.23.0.1,1433

My local SQL Server instance does not allow remote connections. I suspect this is why I cannot connect. Do I need to allow remote connections to get this to work? Can I get this working without doing so?

Also, if I have to provide an IP address, is there a way to work out what that address should be programmatically?

来源:https://stackoverflow.com/questions/45836546/how-to-connect-to-local-sql-server-from-linux-docker-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!