I am new to docker and microservices. As part of my job, I need to containerise a .NET Core application.
It runs fine on IIS express, and loads the following url on startup (which is the correct one):
localhost:9999/swagger/
But when I try running it in a Docker container, it starts up with the following url:
localhost:9999
even if I manually add '/swagger', the application does not run.
What am I doing wrong here?
Here are the contents of my launchSettings.json file:
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:9999/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"web": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "http://localhost:5000/swagger/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger/",
"publishAllPorts": true,
"httpPort": 9999
}
}
}
And here is how my configuration looks like:
Image link
Following are the contents of my Dockerfile:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-nanoserver-1809 AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/core/sdk:3.0-nanoserver-1809 AS build
WORKDIR /src
COPY ["HostServer.csproj", ""]
RUN dotnet restore "./HostServer.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "HostServer.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "HostServer.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "HostServer.dll"]
question from:
https://stackoverflow.com/questions/66056491/net-core-3-0-application-runs-on-iis-express-but-not-docker 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…