尝试使用 dotnet core webapi 项目上传 docker 映像。
云运行的一个要求是监听 8080 端口。
我相信我正在这样做,但是当我在推送到容器注册表后创建云运行服务时,GCP 会返回:
“容器无法启动。无法启动并侦听由 PORT 环境变量定义的端口。此版本的日志可能包含更多信息。”
在本地,我在 8080 上监听了 kestrel。在 8080 上也有容器列表。但是当我按下任何一个时,我都会收到无法启动消息...?有什么建议或尝试这样做吗?
@wlhee Here is the LOG from cloud run:
2019-04-13T05:24:53.462592ZHosting environment: Production
2019-04-13T05:24:53.462657ZContent root path: /app
2019-04-13T05:24:53.462678ZNow listening on: http://[::]:80
2019-04-13T05:24:53.462697ZApplication started. Press Ctrl+C to shut down.
2019-04-13T05:28:48.973934834ZContainer terminated by the container manager on signal 9.
"Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. Logs for this revision might contain more information."
〜码头文件
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim AS base
WORKDIR /app
ENV ASPNETCORE_URLS=http://+:8080
EXPOSE 8080
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build
WORKDIR /src
COPY ["simplecore.csproj", "simplecore/"]
RUN dotnet restore "simplecore/simplecore.csproj"
COPY . .
WORKDIR "/src/simplecore"
RUN dotnet build "simplecore.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "simplecore.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "simplecore.dll"]
~ HERE IS MY MAIN FROM CORE APP
public static void Main(string[] args)
{
//CreateWebHostBuilder(args).Build().Run();
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
//.UseIISIntegration()
.UseStartup<Startup>()
.UseUrls("http://0.0.0.0:8080/")
.Build();
host.Run();
}