-2

I created a simple ASP.NET MVC web application using .Net Core and SQL Server technology stack. I followed the official Microsoft documentation and its working fine with the database. Then I added docker support in my project.

The docker image builds and runs successfully but unable to get data from the SQL Server database. I debug the application and it gives following database connection error.

Error Image

What's the reason for it and how to solve this problem?

Muhammad Zunair
  • 535
  • 1
  • 5
  • 12
  • How is the docker launched? -net=host? Normally you have to enable networking to the host when you launch the container. Just a quick thought on what it may be. – ajankuv Feb 18 '18 at 01:32
  • http://www.loganfranken.com/blog/1345/why-your-web-application-cant-connect-to-sql-server/ – CR241 Feb 18 '18 at 02:14
  • Please add error message instead of saying this `it's giving database connection error.` – TheGameiswar Feb 18 '18 at 02:58

1 Answers1

0

Identify Port used by Named Instance of SQL Server Database Engine by Reading SQL Server Error Logs

The SQL Server Error Log is a great place to find information about what is happening on your database server. The SQL Server Error Log records information with respect to the port in which an instance of the SQL Server Database Engine is listening. You can execute the below TSQL command which uses the XP_READERRORLOG extended stored procedure to read the SQL Server Error Log to find the port the SQL Server Database Engine is listening.

USE master
GO
xp_readerrorlog 0, 1, N'Server is listening on', 'any', NULL, NULL, N'asc' 
GO

Image

For more information MS SQL Tips Page

Raghu Ariga
  • 1,059
  • 1
  • 19
  • 28