web-dev-qa-db-fra.com

Impossible de se lier à http: // localhost: 5000 sur l'interface de bouclage IPv6: "Impossible d'attribuer l'adresse demandée"

J'utilise un modèle de projet compatible avec le docker asp.net core 3.1 (VS2019) pour développer une API Web. Il n'y a aucune erreur de compilation.

Lors de l'exécution du projet, dans la fenêtre de sortie du VS2019, je vois le message suivant:

Unable to bind to http://localhost:5000 on the IPv6 loopback interface: 'Cannot assign requested address'.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.0/System.Collections.NonGeneric.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.0/System.Security.Cryptography.OpenSsl.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.0/System.Security.Cryptography.Encoding.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.0/System.Runtime.Numerics.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Microsoft.AspNetCore.Server.Kestrel: Warning: Unable to bind to https://localhost:5001 on the IPv6 loopback interface: 'Cannot assign requested address'.
[40m[1m[33mwarn[39m[22m[49m: Microsoft.AspNetCore.Server.Kestrel[0]
      Unable to bind to https://localhost:5001 on the IPv6 loopback interface: 'Cannot assign requested address'.
[40m[32minfo[39m[22m[49m: Microsoft.Hosting.Lifetime[0]
      Now listening on: http://localhost:5000
Microsoft.Hosting.Lifetime: Information: Now listening on: http://localhost:5000
[40m[32minfo[39m[22m[49m: Microsoft.Hosting.Lifetime[0]
      Now listening on: https://localhost:5001
Microsoft.Hosting.Lifetime: Information: Now listening on: https://localhost:5001
Microsoft.Hosting.Lifetime: Information: Application started. Press Ctrl+C to shut down.
[40m[32minfo[39m[22m[49m: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
[40m[32minfo[39m[22m[49m: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development
Microsoft.Hosting.Lifetime: Information: Hosting environment: Development
Microsoft.Hosting.Lifetime: Information: Content root path: /src/QueryStack/Author.Query.New.API
[40m[32minfo[39m[22m[49m: Microsoft.Hosting.Lifetime[0]
      Content root path: /src/QueryStack/Author.Query.New.API

Voici mon fichier Docker.develop:

FROM mcr.Microsoft.com/dotnet/core/sdk:3.1
ARG BUILD_CONFIGURATION=Debug
ENV ASPNETCORE_ENVIRONMENT=Development
ENV DOTNET_USE_POLLING_FILE_WATCHER=true    
EXPOSE 80

WORKDIR /src
COPY ["QueryStack/Author.Query.New.API/Author.Query.New.API.csproj", "QueryStack/Author.Query.New.API/"]
COPY ["QueryStack/Author.Query.Persistence/Author.Query.Persistence.csproj", "QueryStack/Author.Query.Persistence/"]
COPY ["Common/Author.Core.Framework/Author.Core.Framework.csproj", "Common/Author.Core.Framework/"]
COPY ["Common/Author.Core.Services.Rediscache/Author.Core.Services.Rediscache.csproj", "Common/Author.Core.Services.Rediscache/"]
COPY ["QueryStack/Author.Query.Domain/Author.Query.Domain.csproj", "QueryStack/Author.Query.Domain/"]
COPY ["Common/Author.Core.Services.Persistence.CosmosDB/Author.Core.Services.Persistence.CosmosDB.csproj", "Common/Author.Core.Services.Persistence.CosmosDB/"]

RUN dotnet restore "QueryStack/Author.Query.New.API/Author.Query.New.API.csproj"
COPY . .
WORKDIR "/src/QueryStack/Author.Query.New.API"
RUN dotnet build --no-restore "Author.Query.New.API.csproj" -c $BUILD_CONFIGURATION

RUN echo "exec dotnet run --no-build --no-launch-profile -c $BUILD_CONFIGURATION --" > /entrypoint.sh

ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]

Quelqu'un peut-il m'aider ici en fournissant ses conseils pour résoudre ce problème

2

Pour contourner le problème, ajoutez le code ENV ASPNETCORE_URLS = http: // +: 8 sous les autres déclarations ENV à la haut du fichier Dockerfile.develop

Dockerfile.develop après:

FROM mcr.Microsoft.com/dotnet/core/sdk:3.1
ARG BUILD_CONFIGURATION=Debug
ENV ASPNETCORE_ENVIRONMENT=Development
ENV DOTNET_USE_POLLING_FILE_WATCHER=true  
ENV ASPNETCORE_URLS=http://+:80  
EXPOSE 80
7
Saiteja Prattipati