I may have encountered an interesting anomaly with the use of Spring Cloud, Eureka and Docker. I am not sure if I have uncovered an issue or if the behavior is expected, but here is the gist.
I start first with eureka running in a named docker container. Next, I launch a docker client with ClientDiscoveryEnabled. The docker client container is using the docker "link" parameter to gain hostname accessibility into the eureka container. The yaml file has an entry for connecting to Eureka that is property driven:
defaultZone: http://user:${eureka.password}@${host.name}:8761/eureka/
Everything works just great, unless I attempt to use an underscore in my container name. If I use an underscore to name my container, the client container cannot resolve this name completely using Eureka registration. If I remove the underscore, everything works fine. Perhaps I missed something and this is expected, but I have not seen any mention of this "feature".
My client is based from the Spring-Cloud-Samples feign-eureka project. Below is the scenario...
This will work and the client will register:
sudo docker run -d -p=8761:8761 --name foobar chrisccoy/microsvcdemoeureka
sudo docker run -d -p=7311:7311 --name democlnt --link foobar:foobar chrisccoy/microsvcdemoclnt java -jar /opt/tst/ms_clnt.jar --host.name=foobar
The following will not work! Eureka will boot, the client will boot, but cannot register:
sudo docker run -d -p=8761:8761 --name foo_bar chrisccoy/microsvcdemoeureka
sudo docker run -d -p=7311:7311 --name democlnt --link foo_bar:foo_bar chrisccoy/microsvcdemoclnt java -jar /opt/tst/ms_clnt.jar --host.name=foo_bar
Below is the log entry and subsequent exception:
2015-02-25 18:51:27.762 ERROR 1 --- [pool-4-thread-1] com.netflix.discovery.DiscoveryClient : Can't get a response from http://user:password@foo_bar:8761/eureka/apps/HELLOCLIENT/172.17.0.11:HelloClient:7311
Can't contact any eureka nodes - possibly a security group issue?
com.sun.jersey.api.client.ClientHandlerException: java.lang.IllegalArgumentException: Host name may not be null
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:184)
at com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEncodingFilter.java:120)
at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:28)
at com.sun.jersey.api.client.Client.handle(Client.java:648)
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:680)
at com.sun.jersey.api.client.WebResource.put(WebResource.java:211)
at com.netflix.discovery.DiscoveryClient.makeRemoteCall(DiscoveryClient.java:1097)
at com.netflix.discovery.DiscoveryClient.makeRemoteCall(DiscoveryClient.java:1060)
at com.netflix.discovery.DiscoveryClient.access$500(DiscoveryClient.java:105)
at com.netflix.discovery.DiscoveryClient$HeartbeatThread.run(DiscoveryClient.java:1583)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: Host name may not be null
at org.apache.http.util.Args.notBlank(Args.java:65)
at org.apache.http.HttpHost.<init>(HttpHost.java:81)
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.getHost(ApacheHttpClient4Handler.java:190)
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:170)
... 14 common frames omitted
I am able to ping "foo_bar" from within a container running /bin/bash without issue.
sudo docker run -i -t --link foo_bar:foo_bar chrisccoy/microsvcdemoclnt /bin/bash
root@0175222c11bb:~# ping foo_bar
PING foo_bar (172.17.0.12) 56(84) bytes of data.
64 bytes from foo_bar (172.17.0.12): icmp_seq=1 ttl=64 time=0.137 ms
I am not sure where the disconnect is coming from. Or maybe it is a feature that I am unaware.
Any ideas?
Looks like java.net.URI
doesn't understand underscore in a domain name. See this gist: https://gist.github.com/spencergibb/ced5199c80f7a6c89499 and this http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6587184
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