title: Unable to start Kestrel in Docker container
body: <p>I have an application written against .NETCore 2.0. I can run the application on my CentOS 7 box in a bash without any problems.</p>
  
  <p>I successfully generated a dockerfile and built a docker image.</p>
  
  <p>When I start the image as container with <code>docker run</code> I get the following exception:</p>
  
  <pre><code>2018-05-09 08:18:02.038 +00:00 [FTL] [Microsoft.AspNetCore.Server.Kestrel] [ThreadId 4] Unable to start Kestrel.
  Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.UvException: Error -99 EADDRNOTAVAIL address not available
     at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.LibuvFunctions.ThrowError(Int32 statusCode)
     at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.UvTcpHandle.Bind(IPEndPoint endPoint)
     at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Listener.ListenTcp(Boolean useFileHandle)
     at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Listener.&lt;&gt;c.&lt;StartAsync&gt;b__8_0(Listener listener)
     at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.LibuvThread.DoPostWork()
  </code></pre>
  
  <p>Don't know what <strong>Address not available</strong> means! This address is not in use in my subnet nor is the configured port.  In C# I use the following code to configure Kestrel:</p>
  
  <p>In my Main()</p>
  
  <pre><code>var wHost = BuildWebHost(args[1]);
  wHost.Run();
  </code></pre>
  
  <p>The <code>BuildWebHost()</code> method is defined as:</p>
  
  <pre><code>    private static IWebHost BuildWebHost(string hostAddress)
      {
          return new WebHostBuilder()
              .UseKestrel()
              .UseContentRoot(Directory.GetCurrentDirectory())
              .UseSerilog()
              .ConfigureAppConfiguration((builderContext, config) =&gt;
              {
                  config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
              })
              .UseDefaultServiceProvider((context, options) =&gt;
              {
                  options.ValidateScopes = context.HostingEnvironment.IsDevelopment();
              })
              .UseStartup&lt;Startup&gt;()
              .UseUrls($"http://{hostAddress}:{ServerPort}")
              .Build();
      }
  </code></pre>
  
  <p>The IP address is passed as argument and <code>ServerPort</code> is a constant. In the Docker file I have</p>
  
  <pre><code>ENTRYPOINT ["dotnet", "OperationsManagerServer.dll", "/logs", "172.16.63.250"]
  </code></pre>
  
  <p>Before starting Kestrel the service does a lot of initialization such as loading configruations from a Redis database and initializing things on a MongoDB server. These servers are running on different machines in the same subnet and this just works fine. So I guess networking in my container works.</p>
  
  <p>Any idea what is wrong with Kestrel when it runs inside a container??</p>