Docker“无法绑定”

时间:2019-09-25 19:13:49

标签: docker .net-core

我已经构建了我的第一个.net core 3.0 docker映像,但是当尝试运行该映像时,docker返回一些错误。

我尝试了许多端口配置。我尝试导航到localhost ip而不是localhost。我也用Google搜索了更多的信息。

PS C:\Users\jamie\source\repos\Angular\Angular> docker run -it -p 8080:80 angular
warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
      Storing keys in a directory '/root/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
      No XML encryptor configured. Key {b5292a1f-2d9a-456a-815f-90f19bfe21b1} may be persisted to storage in unencrypted form.
warn: Microsoft.AspNetCore.Server.Kestrel[0]
      Unable to bind to http://localhost:5000 on the IPv6 loopback interface: 'Cannot assign requested address'.
warn: Microsoft.AspNetCore.Server.Kestrel[0]
      Unable to bind to https://localhost:5001 on the IPv6 loopback interface: 'Cannot assign requested address'.
Hosting environment: Production
Content root path: /app
Now listening on: http://localhost:5000
Now listening on: https://localhost:5001
Application started. Press Ctrl+C to shut down.

另外,这是我的dockerfile

FROM mcr.microsoft.com/dotnet/core/sdk:3.0
WORKDIR /app
COPY bin/Debug/netcoreapp3.0/publish .
ENTRYPOINT [ "dotnet", "Angular.dll"]

1 个答案:

答案 0 :(得分:0)

这些只是警告,但是我认为来自应用程序端口的问题,因为服务器运行的方式与您看到的不同

Now listening on: http://localhost:5000
Now listening on: https://localhost:5001

因此请尝试绑定50005001

docker run -it -p 8080:5000 angular

or

docker run -it -p 8080:5001 angular

正如大卫提到的,您还需要倾听 尝试添加 ENTRYPOINT [ "dotnet", "Angular.dll", "--urls", "http://0.0.0.0:5000"](如果不是),请按照评论链接中的答案