2

I'm publishing an application to docker image microsoft/dotnet:1.0.1-core that reference Sql Server instance in connection string:

"Data Source=host\instance;Initial Catalog=database;User ID=user;Password=pass;"

In Windows environment it work's as well, but using docker, the application cannot connect to the database. Changing the Data Source to use port instead of instance it works.

"Data Source=host,port;Initial Catalog=database;User ID=user;Password=pass;"

How can I connect, from docker, to Sql Server using instance instead port?

4
  • "the application cannot connect to the database" is there a specific error message? Commented Nov 8, 2016 at 16:04
  • 1
    Does "SQL Server Browser" runs on the database machine? Commented Nov 8, 2016 at 16:05
  • Not just SQL Server Broswer, but you also need to allow UDP port 1434 through. Commented Nov 8, 2016 at 16:16
  • I had some difficulties with this on Ubuntu 22.04 and discovered how to resolve it and wrote up an answer at: stackoverflow.com/questions/60008593/… Commented Aug 14, 2023 at 12:02

1 Answer 1

2

According to Saurabh Singh from Microsoft:

The Instance name support is available in v 1.1 of .Net Core. In v1.0 of .Net Core, Instance names are not supported on OS other than Windows.

So I don't think you can connect from .Net Core 1.0 running on Linux to an SQL Server using instance name.

Your choices seem to be:

  • don't use instance name
  • wait for .Net Core 1.1 (planned for "Fall 2016")
  • use pre-release version of .Net Core 1.1
Sign up to request clarification or add additional context in comments.

1 Comment

That's not a .NET Core issue. Instance names are in general a Windows concept. In a docker container, running Linux, the SQL Server will be available through ip/port. Also, usually one container is like just one instance. If you need multiple instances, create multiple containers instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.