关于asp.net core打包到docker,然后设置成https
大佬们,求指教,谢了。
asp.net core
return WebHost.CreateDefaultBuilder(args)
//.UseUrls("https://*:5001")
.UseStartup<Startup>()
.ConfigureKestrel(options =>
{
options.Listen(IPAddress.Loopback, 5001, listenOptions =>
{
listenOptions.UseHttps("server.pfx", "linezero");
});
})
.Build();
dockerfile
FROM mcr.microsoft.com/dotnet/core/runtime:2.2 AS base
WORKDIR /safety_experience_hall
EXPOSE 5001
FROM base AS final
WORKDIR /safety_experience_hall
COPY . /safety_experience_hall
ENV ASPNETCORE_ENVIRONMENT Production
ENTRYPOINT ["dotnet", "Qianbian.SafetyExperienceHall.Web.Host.dll"]
容器
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5c04e916d71d safety_experience_hall:v7 "dotnet Qianbian.Saf…" 13 seconds ago Up 12 seconds 0.0.0.0:9595->5001/tcp goofy_snyder
运行结果
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using '/root/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[58]
Creating key {dba781f4-67f0-45ec-b28f-c0619369ee8b} with creation date 2019-08-15 03:52:58Z, activation date 2019-08-15 03:52:58Z, and expiration date 2019-11-13 03:52:58Z.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {dba781f4-67f0-45ec-b28f-c0619369ee8b} may be persisted to storage in unencrypted form.
info: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[39]
Writing data to file '/root/.aspnet/DataProtection-Keys/key-dba781f4-67f0-45ec-b28f-c0619369ee8b.xml'.
warn: Microsoft.AspNetCore.Server.Kestrel[0]
Overriding address(es) 'http://+:80'. Binding to endpoints defined in UseKestrel() instead.
Hosting environment: Production
Content root path: /safety_experience_hall
Now listening on: https://127.0.0.1:5001
Application started. Press Ctrl+C to shut down.
回答
你访问的IP错了,不是127.0.0.1,应该是192.168.99.100:9595