Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Hi,
I created a clean, default ASP.NET Core Web API project. The project name is "WebApplication4". I didn't change a thing in the project. So, everything is intact. I ran this project in release mode & docker. No problem until this point. I closed the docker container and tried to rerun the docker image using command line. My command was docker run -it -p 8080:8080 webapplication4:latest
. I tried to access https://localhost:8080/swagger
and https://localhost:8080/swagger/index.html
. However, none of them is opening and I got an error like this ERR_SSL_PROTOCOL_ERROR
.
To fix this, I cleaned all SSL protocols defined before and redefined it by trusting. It did not help. No change in the behaviour.
-> dotnet dev-certs https --clean
-> dotnet dev-certs https
This behavior did not happen before until I updated my visual studio for .net 8.
The docker file is:
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["WebApplication4/WebApplication4.csproj", "WebApplication4/"]
RUN dotnet restore "./WebApplication4/./WebApplication4.csproj"
COPY . .
WORKDIR "/src/WebApplication4"
RUN dotnet build "./WebApplication4.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./WebApplication4.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "WebApplication4.dll"]
The launchSettings.json file is:
{
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5117"
},
"https": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7099;http://localhost:5117"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"environmentVariables": {
"ASPNETCORE_HTTPS_PORTS": "8081",
"ASPNETCORE_HTTP_PORTS": "8080"
},
"publishAllPorts": true,
"useSSL": true
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:15057",
"sslPort": 44358
}
}
}
Expected Behavior
https://localhost:8080/swagger
url should have been accessed successfully after running the docker from command line.
Steps To Reproduce
-> Open Visual Studio 17.8.0.
-> Create a ASP.NET Core Web API with default settings.
-> Run once in release mode in docker.
-> Close the container.
-> Rerun the docker image via command line terminal using docker run -it -p 8080:8080 webapplication4:latest
.
-> The server is not accessible via https://localhost:8080/swagger
.
Exceptions (if any)
No response
.NET Version
8.0.100
Anything else?
Visual Studio 17.8.0
.NET 8.0.100