【问题标题】:Can't start ASP.NET Core web API Docker on a specified port无法在指定端口上启动 ASP.NET Core Web API Docker
【发布时间】:2018-02-28 12:34:35
【问题描述】:

这是我的 Dockerfile:

  FROM microsoft/aspnetcore-build:1.0 AS build-env

  WORKDIR /app

  # copy csproj and restore as distinct layers

  COPY *.csproj ./

  RUN dotnet restore

  # copy everything else and build

  COPY . ./

  RUN dotnet publish -c Release -o out

  # build runtime image

  FROM microsoft/aspnetcore:1.0

  WORKDIR /app

  COPY --from=build-env /app/out .

  EXPOSE 58912

  ENTRYPOINT ["dotnet", "SgaApi.dll"]

我使用这个命令构建:docker build -f Dockerfile -t sga .

运行:docker run -e "ASPNETCORE_URLS=http://+:58912" -it --rm sga

Application starts successfully

我无法从浏览器访问它。当我使用“dotnet run”运行应用程序时,它工作正常。

【问题讨论】:

    标签: docker asp.net-web-api dockerfile asp.net-core-1.1


    【解决方案1】:

    你已经暴露了端口,但你还没有发布它。您可以使用 -P 发布所有公开的端口或 -p 然后指定端口映射。例如:

    docker run -p 58912:58912 -e "ASPNETCORE_URLS=http://+:58912" -it --rm sga
    

    【讨论】:

      猜你喜欢
      • 2019-02-11
      • 2021-07-22
      • 2022-10-16
      • 1970-01-01
      • 1970-01-01
      • 2017-01-03
      • 2021-10-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多