我尝试仅通过docker连接到我的MSSQL数据库时遇到问题,我已经尝试使用IIS Express并正确显示数据,但是当我尝试从请求中获取数据时出现此错误。
SqlException: 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)
我确认启用了TCP / IP以及1433端口。还使用此字符串连接
"TestConnection": "Server=localhost,1433;Database=BDREPOSITORIO;Integrated Security=True"
而我的dockerfile是这个
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
COPY ["Buscador.csproj", ""]
RUN dotnet restore "./Buscador.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "Buscador.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Buscador.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Buscador.dll"]
RUN sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /etc/ssl/openssl.cnf
RUN sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /usr/lib/ssl/openssl.cnf
您的连接字符串只有两个问题:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句