dotnet运行挂起在正在运行的Docker容器中

dotnet运行挂起在正在运行的Docker容器中,docker,.net-core,Docker,.net Core,我有一个棱角分明的8.NET核心应用程序,我正试图在Docker中运行。我可以成功创建Docker映像并在分离模式下运行容器。我能够执行到正在运行的容器中,进入Angular文件夹并成功地运行ngserve--host 0.0.0。当我转到.NET文件夹并运行dotnet run时,它挂起在“使用来自…/launchsettings.json的启动设置”。在Dockerfile中,我使用行expose 80公开端口80。运行容器时,我会映射Angular前端(4200)和.NET后端(5000)

我有一个棱角分明的8.NET核心应用程序,我正试图在Docker中运行。我可以成功创建Docker映像并在分离模式下运行容器。我能够执行到正在运行的容器中,进入Angular文件夹并成功地运行
ngserve--host 0.0.0
。当我转到.NET文件夹并运行
dotnet run
时,它挂起在“使用来自…/launchsettings.json的启动设置”。在Dockerfile中,我使用行
expose 80
公开端口80。运行容器时,我会映射Angular前端(4200)和.NET后端(5000)的端口,如下所示:

docker run -it --rm -d -p 4200:4200 -p 5000:80 portal /bin/bash
在容器中运行
dotnet run
时,我没有收到任何错误。如何让
dotnet运行
完成

更新: 这是我的Dockerfile:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /app/
EXPOSE 80

#install node and npm
RUN apt-get update -yq && apt-get upgrade -yq && apt-get install -yq curl git nano
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - && apt-get install -yq nodejs build-essential

#install angular-cli
RUN npm install -g @angular/cli

RUN mkdir library
#add local nuget packages
ADD ./library/. /app/library

RUN mkdir Web
COPY ./Web/. /app/Web
RUN cd Web && npm install

RUN mkdir API

# currently in the app folder
COPY ./API/Api.csproj /app/API
ENV DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0
COPY ./API/NuGet.config /app/API

RUN cd API && dotnet restore

#copies all files into current directory
COPY ./API/. /app/API
以下是我的launchsettings.json:

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:52121",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "API": {
      "commandName": "Project",
      "launchBrowser": false,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "http://localhost:5000/"
    }
  }
}
更新2: 我找到了一个.NET Core Docker示例应用程序
我将示例应用程序的launchsettings.json中的端口80配置文件添加到我的launchsettings.json中,但没有成功。在这一点上我完全被难住了。我在docker容器中使用“-verbosity detailed”运行了“dotnet run”,没有收到任何警告或错误。我怀疑这可能与数据库连接有关,但我甚至不知道从何处着手解决问题。

您应该添加另一个配置文件,其中包含有关Docker设置的信息。正如微软在他们的网站上提到的

默认配置文件信息为

"Docker": {
  "commandName": "Docker",
  "launchBrowser": true,
  "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
  "environmentVariables": {
    "ASPNETCORE_URLS": "https://+:443;http://+:80",
    "ASPNETCORE_HTTPS_PORT": "44360"
  },
  "httpPort": 51803,
  "useSSL": true,
  "sslPort": 44360
}

launchSettings.json

  "applicationUrl": "http://0.0.0.0:5000/"

我的回答对你们中的一些人来说可能很有趣,但相信我,这发生在我身上,我想,
docker run
被卡住了,但实际上不是,事实是,在前一个开发人员成功运行的情况下,没有记录任何内容


这是成功的运行,没有任何东西被卡住

你能显示Dockerfile和launchsettings.json吗?@Kevin我添加了我的Dockerfile和launchsettings.json你能尝试将'API'配置文件中的'commandName'更改为'Docker'吗?是否有可用的Docker日志?我已将您上面提供的Docker配置文件添加到我的launchsetting.json中,dotnet运行仍然挂起在“使用来自…的启动设置”,而此代码可能会回答此问题,提供有关如何和/或为什么解决此问题的其他上下文将提高答案的长期价值。此外,问题中的哪个应用程序URL需要替换为此?