I have two containers: ASP.NET Core app (name: DockerApp) and an MSSQL Server (name: DockerSQLServer). They are on the same custom network (name: backend).
But when DockerApp tries connect to the DockerSQLServer it encounters an error:
Unhandled exception. Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 35 - An internal exception was caught)
The connection string is correct, I suppose: Server=DockerSQLServer,1433;Database={database};MultipleActiveResultSets=true;User Id=sa;Password={password}
If I do the same in Windows 10 Docker, it works well.
But when DockerApp tries connect to the DockerSQLServer it encounters an error:
Unhandled exception. Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 35 - An internal exception was caught)
The connection string is correct, I suppose: Server=DockerSQLServer,1433;Database={database};MultipleActiveResultSets=true;User Id=sa;Password={password}
If I do the same in Windows 10 Docker, it works well.