运行Docker镜像会导致Kestrel异常

时间:2017-07-25 06:58:05

标签: c# asp.net docker jenkins

当我尝试在Linux OS中运行我的docker镜像时,我面临着奇怪的行为 - 该图像包含.Net核心Web API项目

这是我的Program.cs

 var host = new WebHostBuilder()
.UseKestrel().UseStartup<Startup>().Build();
 host.Run();

我的Docker-compose.yml文件

version: '2'
services:
server:
    image: repo.testCompany.com:1443/testCompany:6
    ports:
    - "60000:60000"
    hostname: ucp.${HOST_HOSTNAME}
    restart: unless-stopped

图像构建并成功推送。当Web API尝试在容器内运行项目并抛出运行时异常时出现问题 -

Unhandled Exception: System.AggregateException: One or more errors occurred. 
(Error -99 EADDRNOTAVAIL address not available) ---> 
Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvException: Error 
-99 EADDRNOTAVAIL address not available
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.Check(Int32 
statusCode)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.tcp_bind(UvTcpHandle handle, SockAddr& addr, Int32 flags)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle.Bind(ServerAddress address)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.TcpListener.CreateListenSocket()
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Listener.<>c.<StartAsync>b__6_0(Object state)
 --- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
 at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelEngine.CreateServer(ServerAddress address)
   at Microsoft.AspNetCore.Server.Kestrel.KestrelServer.Start[TContext](IHttpApplication`1 application)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.Start()
at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host, CancellationToken token, String shutdownMessage)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
at Exactor.XeroConnector.API.Program.Main(String[] args)

主要问题是我的本地计算机上没有重现错误,只有在构建映像并通过Jenkins上传时才会出现错误。 你能不能请一个人提出建议。

1 个答案:

答案 0 :(得分:0)

Tnx的答案问题是詹金斯不知何故不发布最新的图像......