Docker nancy - no route to host

I have a docker container that hosts a web api written in Nancy. The following is an exception that occurs after the web request is executed when the container is first launched:

4/22/2016 2:40:50 PM at API.SearchModule+<SearchModule>c__AnonStorey0.<>m__0 (System.Object _) <0x41380aa0 + 0x00850> in <filename unknown>:0 4/22/2016 2:40:50 PM at (wrapper dynamic-method) System.Object:CallSite.Target (System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,System.Func`2<object, object>,object) 4/22/2016 2:40:50 PM at Nancy.Routing.Route+<>c__DisplayClass4.<Wrap>b__3 (System.Object parameters, CancellationToken context) <0x4133d350 + 0x00166> in <filename unknown>:0 4/22/2016 2:40:50 PM2016-04-22 13:40:50,177 ERROR: System.Net.WebException: Error: ConnectFailure (No route to host) ---> System.Net.Sockets.SocketException: No route to host 4/22/2016 2:40:50 PM at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) <0x41374320 + 0x001b8> in <filename unknown>:0 4/22/2016 2:40:50 PM at System.Net.WebConnection.Connect (System.Net.HttpWebRequest request) <0x41372b50 + 0x00609> in <filename unknown>:0 

The application requests elasticsearch when the web request is done, initially I thought it explodes because it cannot find elastic (another container for dockers), however this does not seem to be the case locally if I stop the elastic api will continue Serve requests, although it will throw exceptions. As soon as the elastic returns to the network, api continues to serve requests this time without exception.

The bizarre thing is if the docker container restarts again, the web requests against api succeed with the request for elasticity.

Anyway, can I replicate this problem locally to try to fix the error? I thought that if I ran it locally using offline autonomous mode, I would get the same error, however it doesn't seem to be that way that makes me think about some kind of network connection problem.

What do you think it could be?

+6
source share
1 answer

This is a DNS problem. Your docker container cannot resolve the IP address for the provided URL (Host).

Look at the --dns ( https://docs.docker.com/engine/reference/run/#network-settings ) or make changes to the resolv.conf file inside your docker image / container.

+1
source

All Articles