We have a .net core app that will be containerized on linux. I want to know how we can make this app talk to the SQL server 2016 over the network.
Just like you would if the app wasnt in a container, the container still has access to the local network to communicate with other services
Thank you @terpz. I tried to connect to the SQL server 2017 on the network from my container and receive the below error. the sql.open() when encountered in the code just hangs. I am using the “using” block for sql connection and made sure the sql connection is not left open.
The error is:
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: 40 - Could not open a connection to SQL Server)
and my Dockerfile looks like:
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-bionic AS base
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-bionic AS build
COPY [“EmployeeManagement/EmployeeManagement.csproj”, “EmployeeManagement/”]
RUN dotnet restore “EmployeeManagement/EmployeeManagement.csproj”
COPY . .
RUN dotnet build “EmployeeManagement.csproj” -c Release -o /app/build
FROM build AS publish
RUN dotnet publish “EmployeeManagement.csproj” -c Release -o /app/publish
FROM base AS final
COPY --from=publish /app/publish .
ENTRYPOINT [“dotnet”, “EmployeeManagement.dll”]
Any help is appreciated.