Reputation: 61
The main reason why I am asking this is because I have tried literally everything.
Here is my configuration:
Configuration string
"Server=db-server;Database=TestDB;User=sa;Password=Test1234;SslMode=None;"
docker-compose:
version: "3.5"
networks:
localdev:
name: localdev
services:
main-api:
build:
context: .
dockerfile: src/TestApp/Dockerfile
restart: always
ports:
- "5001:5001"
environment:
ASPNETCORE_ENVIRONMENT: "Development"
ASPNETCORE_URLS: "http://+:5001"
depends_on:
- db-server
networks:
- localdev
volumes:
- ./tmp:/app/tmp
db-server:
image: "mcr.microsoft.com/mssql/server:2019-CU3-ubuntu-18.04"
container_name: db-server
environment:
ACCEPT_EULA: "Y"
SA_PASSWORD: "Test1234"
ports:
- "1400:1433"
networks:
- localdev
Dockerfile
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-bionic AS base
RUN sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /etc/ssl/openssl.cnf
RUN sed -i 's/MinProtocol = TLSv1.2/MinProtocol = TLSv1/g' /etc/ssl/openssl.cnf
RUN sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /usr/lib/ssl/openssl.cnf
RUN sed -i 's/MinProtocol = TLSv1.2/MinProtocol = TLSv1/g' /usr/lib/ssl/openssl.cnf
WORKDIR /app
EXPOSE 5001
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-bionic AS build
WORKDIR /src
COPY ["src/TestApp.API/TestApp.API.csproj", "src/TestApp.API/"]
COPY ["src/TestApp.Infrastructure/TestApp.Infrastructure.csproj", "src/TestApp.Infrastructure/"]
COPY ["src/TestApp.Domain/TestApp.Domain.csproj", "src/TestApp.Domain/"]
COPY ["src/TestApp.ApplicationCore/TestApp.ApplicationCore.csproj", "src/TestApp.ApplicationCore/"]
RUN dotnet restore "src/TestApp.API/TestApp.API.csproj"
COPY . .
WORKDIR "/src/src/TestApp.API"
RUN dotnet build "TestApp.API.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "TestApp.API.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "TestApp.API.dll"]
I also go into my db-server container after docker-compose build
and create TestDB, then I check and I can connect to that database from my host SSMS, but whenever I try to run my TestApp container, I get this error there
Host terminated unexpectedly
main-api_1 | Microsoft.Data.SqlClient.SqlException (0x80131904): Login failed for user 'sa'.
and also in my database server logs I find this error
Login failed for user 'sa'. Reason: Password did not match that for the login provided.
I tried literally everything. As you can see, I changed to bionic docker images, tried to follow this, but nothing works. Password is correct, as I can connect to the cli inside container I use following password and I can use that password from my host machine as well - but not from TestApp container.
Upvotes: 1
Views: 1254
Reputation: 61
It appears that i am dumb and was changing password in appsettings.json
and not in appsettings.Development.json
, and that happened because Visual Studio hides that file under appsettings.json
.
Upvotes: 3