Dockerfile
FROM microsoft/dotnet:2.1-aspnetcore-runtime
WORKDIR /app
COPY ./publish .
ENTRYPOINT ["dotnet", "WebApiTestNew1.dll"]
Program.cs
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseContentRoot(Directory.GetCurrentDirectory()) // 这段解决部署到docker中,出现404错误
.UseStartup<Startup>();
出现404的原因: https://blog.agchapman.com/resolving-404-errors-when-publishing-asp-net-core-for-docker/