I have a docker container which hosts a web api written in Nancy. Here is the exception that occurs after a web request is made when the container is first fired up:
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 app queries elasticsearch when a web request is made, initially I thought it was blowing up because it couldn't find elastic (another docker container), however this doesn't seem to be the case as locally if I stop elastic the api will continue serving requests albeit it will throw exceptions. Once elastic is back online, the api continues to serve requests this time without exceptions.
The bizarre thing is if the docker container is restarted again the web requests against the api are successful at querying elastic.
Is there anyway I can replicate this issue locally so I can attempt to work on a fix? I had thought that if I run it locally with elastic offline I would get the same error, however this doesn't seem to be the case which makes me think it's some sort of network connectivity issue.
What do you guys think it could be?
It is a DNS problem. Your docker container is unable to resolve the IP address for the provided URL (Host).
Take a look to the --dns
option (https://docs.docker.com/engine/reference/run/#network-settings) or amend the resolv.conf
file inside your docker image/container.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With