Docker dotnet watch run错误:无法绑定到IPv6环回接口上的https: localhost:5000

Docker dotnet watch run错误:无法绑定到IPv6环回接口上的https: localhost:5000,第1张

Docker dotnet watch run错误:无法绑定到IPv6环回接口上的https:// localhost:5000

我自己就遇到了这个问题。我认为

dotnet watchrun
与localhost类型的url配合不好。尝试
https://0.0.0.0:5000
在您的容器中将托管网址设置为。

在dockerfile中,带有:

ENTRYPOINT [ "dotnet", "watch", "run", "--no-restore", "--urls", "https://0.0.0.0:5000"]

或在launchSettings.json中,例如:

{  "profiles": {    "[Put your project name here]": {      "commandName": "Project",      "launchBrowser": true,      "environmentVariables": {        "ASPNETCORE_ENVIRONMENT": "Development",        "DOTNET_USE_POLLING_FILE_WATCHER": "true"      },      "applicationUrl": "https://0.0.0.0:5000/"    }  }}

现在,要使其自动从容器中重新加载,您必须使用轮询文件监视程序。这就是第二个环境变量的用途。(这很常见,您必须使用webpack,angular等来执行此 *** 作)。

在您的情况下,您需要将更

esportsapp.volume
改为主机上的目录:

volumes:  - ./:/app

它将容器中的/ app卷映射到docker-compose目录。您面临的问题是该应用程序内置在项目默认的docker-
compose网络上的某个卷中,因此,当您在源目录中更改文件时,该卷中实际上并没有更改。但是,使用此修复程序,您将遇到容器内部dotnet恢复和dotnet监视更改主机文件的问题。如果您有兴趣,可以解决所有问题…

我通常的.Net Core App Docker设置

要调试,请运行:

docker-compose -f run.yml up --build

要构建发行版:

docker-compose -f build.yml up --build

项目结构

/   # source control root/build.yml     # docker-compose file for building a release/run.yml       # docker-compose file for running locally & debugging/project       # an application/project/build.Dockerfile # the docker container that will build "project" for release/project/run.Dockerfile   # the docker container that will build and run "project" locally for debugging/project/.dockerignore    # speeds up container builds by excluding large directories like "packages" or "node_modules"/project/src   # where I hide my source prez/project/src/Project.sln/project/src/Project/Project.csproj/project/src/Project/Directory.Build.props      # keeps a docker mapped volume from overwriting .dlls on your host/project/src/Project.Data/Project.Data.csproj   # typical .Net project structure/web-api       # another application...

Directory.Build.props (将其与.csproj放在同一文件夹中,

dotnet watchrun
以免使命令与主机上的源目录混淆)

<Project>  <PropertyGroup>    <DefaultItemExcludes>$(DefaultItemExcludes);$(MSBuildProjectDirectory)/obj*</DefaultItemExcludes>    <DefaultItemExcludes>$(DefaultItemExcludes);$(MSBuildProjectDirectory)/bin*</DefaultItemExcludes>  </PropertyGroup>  <PropertyGroup Condition="'$(DOTNET_RUNNING_IN_CONTAINER)' == 'true'">    <baseIntermediateOutputPath>$(MSBuildProjectDirectory)/obj/container/</baseIntermediateOutputPath>    <baseOutputPath>$(MSBuildProjectDirectory)/bin/container/</baseOutputPath>  </PropertyGroup>  <PropertyGroup Condition="'$(DOTNET_RUNNING_IN_CONTAINER)' != 'true'">    <baseIntermediateOutputPath>$(MSBuildProjectDirectory)/obj/local/</baseIntermediateOutputPath>    <baseOutputPath>$(MSBuildProjectDirectory)/bin/local/</baseOutputPath>  </PropertyGroup></Project>

run.yml用于调试的docker-compose.yml)

version: "3.5"services:  project:    build:      context: ./project      dockerfile: run.Dockerfile    ports:      - 5000:80    volumes:      - ./project/src/Project:/app

run.Dockerfile (用于调试的Dockerfile)

FROM microsoft/dotnet:2.1-sdk# install the .net core debuggerRUN apt-get updateRUN apt-get -y --no-install-recommends install unzipRUN apt-get -y --no-install-recommends install procpsRUN rm -rf /var/lib/apt/lists/*RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l /vsdbgVOLUME /appWORKDIR /appCMD dotnet watch run --urls http://0.0.0.0:80

build.yml (用于构建发行版的docker-compose.yml)

version: "3.5"services:  project:    build:      context: ./project      dockerfile: build.Dockerfile    volumes:      - ./project:/app

build.Dockerfile (用于构建发行版的Dockerfile)

FROM microsoft/dotnet:2.1-sdkVOLUME /app# restore as a separate layer to speed up buildsWORKDIR /srcCOPY src/Project/Project.csproj .RUN dotnet restoreCOPY src/Project/ .CMD dotnet publish -c Release -o /app/out/


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4897917.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-12
下一篇 2022-11-12

发表评论

登录后才能评论

评论列表(0条)

保存