So I have been trying to fix this problem, and 4 days later I still haven't been able to find a solution. I have built an API Gateway using Spring Boot which acts as a Eureka Server via Zuul, and I have a microservice which acts as a Eureka Client. When I run it locally within Intellij, everything works perfect and they discover and connect to eachother. When they are in a container however, I get the following exception:
2022-05-16 12:42:49.087 WARN 1 --- [nfoReplicator-0]
c.n.d.s.t.d.RetryableEurekaHttpClient : Request execution failed
with m essage: java.net.UnknownHostException: http 2022-05-16
12:42:49.088 WARN 1 --- [nfoReplicator-0]
com.netflix.discovery.DiscoveryClient :
DiscoveryClient_USER/8322e6fdb2 35:user:8082 - registration failed
Cannot execute request on any known server
com.netflix.discovery.shared.transport.TransportException: Cannot
execute request on any known server
at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:112
) ~[eureka-client-1.9.17.jar!/:1.9.17]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56
) ~[eureka-client-1.9.17.jar!/:1.9.17]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:5
9) ~[eureka-client-1.9.17.jar!/:1.9.17]
at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77)
~[eureka-client-1.9.17.jar!/:1.9.17]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56
) ~[eureka-client-1.9.17.jar!/:1.9.17]
at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:850)
~[eureka-client-1.9.17.jar!/:1.9.17]
at com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:121)
[eureka-client-1.9.17.jar!/:1.9.17]
at com.netflix.discovery.InstanceInfoReplicator$1.run(InstanceInfoReplicator.java:101)
[eureka-client-1.9.17.jar!/:1.9.1 7]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[na:1.8.0_332]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_332]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
[na:1.8.0_332]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
[na:1.
8.0_332]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[na:1.8.0_332]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[na:1.8.0_332]
at java.lang.Thread.run(Thread.java:750) [na:1.8.0_332]
My Eureka Server looks like this:
Docker-compose.yaml
version: '3.8'
services:
kwettergateway-docker:
image: user/kwettergateway
ports:
- "8761:8761"
userservice-docker:
image: user/userservice
ports:
- "8082:8082"
links:
- kwettergateway-docker
Application.properties:
server.port=8761
#Gateway properties
spring.application.name=gateway
eureka.instance.prefer-ip-address=true
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.server.wait-time-in-ms-when-sync-empty=0
zuul.prefix=/api
zuul.routes.user.path=/user/**
zuul.routes.user.url=http://localhost:8082/
Dockerfile:
FROM openjdk:8
EXPOSE 8080
ADD target/kwettergateway-docker.jar kwettergateway-docker.jar
ENTRYPOINT ["java", "-jar", "/kwettergateway-docker.jar"]
My Eureka Client looks like this:
Application.properties:
server.port=8082
#Gateway properties
spring.application.name=user
eureka.instance.prefer-ip-address=true
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
I had to use the docker host instead of localhost. So it's working now with the following code:
eureka.client.serviceUrl.defaultZone=http://host.docker.internal:8761/eureka/
You trying to run your application using Docker, so in your application.properties file you should replace localhost to image name. Also, what need to mention, that you should mark you Eureka server with #EnableEurekaServer.
If you want to have a look on it, visit - https://github.com/zhurasique/easycar
Related
I developed a spring boot application to store login information via redis. I have following docker-compose.yml:
version: "3.9"
services:
web:
build: .
ports:
- "8082:8082"
links:
- redis
redis:
image: redis
container_name: redis
hostname: redis-db
ports:
- "6379:6379"
command: redis-server --port 6379 --bind 0.0.0.0 --protected-mode no
Dockerfile:
FROM openjdk:8-jre-alpine
VOLUME /tmp
COPY app.jar app.jar
EXPOSE 8082
ENTRYPOINT ["java", "-jar", "app.jar"]
In the Spring Boot Application, I just use following application.properties to setup the Redis Connection:
server.port = 8082
spring.redis.host=redis-db
spring.redis.port=6379
I access the repository via CrudRepository and QueryByExampleExecutor. Every time I try to access the data, I get the following error:
sgartner-web-1 | 2021-11-25 01:22:53.600 ERROR 1 --- [nio-8082-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to localhost:6379] with root cause
sgartner-web-1 |
sgartner-web-1 | java.net.ConnectException: Connection refused
sgartner-web-1 | at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_212]
sgartner-web-1 | at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[na:1.8.0_212]
sgartner-web-1 | at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:330) ~[netty-transport-4.1.69.Final.jar!/:4.1.69.Final]
sgartner-web-1 | at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334) ~[netty-transport-4.1.69.Final.jar!/:4.1.69.Final]
sgartner-web-1 | at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:707) ~[netty-transport-4.1.69.Final.jar!/:4.1.69.Final]
sgartner-web-1 | at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655) ~[netty-transport-4.1.69.Final.jar!/:4.1.69.Final]
sgartner-web-1 | at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581) ~[netty-transport-4.1.69.Final.jar!/:4.1.69.Final]
sgartner-web-1 | at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) ~[netty-transport-4.1.69.Final.jar!/:4.1.69.Final]
sgartner-web-1 | at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) ~[netty-common-4.1.69.Final.jar!/:4.1.69.Final]
sgartner-web-1 | at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.69.Final.jar!/:4.1.69.Final]
sgartner-web-1 | at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.69.Final.jar!/:4.1.69.Final]
sgartner-web-1 | at java.lang.Thread.run(Thread.java:748) [na:1.8.0_212]
I already have tested the application "normal" instances of redis and the application. What seems odd to me is the "Unable to connect to localhost:6379]", even though I'm not trying to connect to localhost.
Testing this behavior while running the application outside of a container shows, that it recognises the changed hostname and doesn't try to connect to localhost...
The specified redis command also doesn't seem to be the problem: tested this with running redis outside of a container with the same command and trying to connect to it via a VM.
I would really appreciate a solution or another possible cause to look into. Thanks to whoever replies to this!
as per logs it clearly says that web application is not able to connect to redis port 6379. Can you try expose 6379 in Dockerfile? , please check first are you able to pint 6379 from your local machine. Seems network issue.
See is this helps.
Docker can't connect to redis from another service
I'm trying to run a test code using remote elasticsearch cluster.
The only configurations that I have are remote ES cluster addresses.
But suddenly my code looking for localhost:9200 ES cluster.
Any of you knows What happened?
Logs in test results
1. Prove for remote ES cluster connection (maybe?)
2021-09-09 23:48:18.302 DEBUG 52659 --- [ Test worker] org.elasticsearch.client.RestClient : request [GET http://{my-remote-elasticsearch-host}:{port}/] returned [HTTP/1.1 200 OK]
2021-09-09 23:48:18.336 INFO 52659 --- [ Test worker] o.s.d.elasticsearch.support.VersionInfo : Version Spring Data Elasticsearch: 4.2.3
2021-09-09 23:48:18.337 INFO 52659 --- [ Test worker] o.s.d.elasticsearch.support.VersionInfo : Version Elasticsearch Client in build: 7.12.1
2021-09-09 23:48:18.337 INFO 52659 --- [ Test worker] o.s.d.elasticsearch.support.VersionInfo : Version Elasticsearch Client used: 7.12.1
2021-09-09 23:48:18.337 INFO 52659 --- [ Test worker] o.s.d.elasticsearch.support.VersionInfo : Version Elasticsearch cluster: 7.10.1
2021-09-09 23:48:18.337 WARN 52659 --- [ Test worker] o.s.d.elasticsearch.support.VersionInfo : Version mismatch in between Elasticsearch Client and Cluster: 7.12.1 - 7.10.1
2. Unexpected attempt to the localhost:9200
reactor.core.Exceptions$ErrorCallbackNotImplemented: org.springframework.data.elasticsearch.client.NoReachableHostException: Host 'localhost:9200' not reachable. Cluster state is offline.
Caused by: org.springframework.data.elasticsearch.client.NoReachableHostException: Host 'localhost:9200' not reachable. Cluster state is offline.
at org.springframework.data.elasticsearch.client.reactive.SingleNodeHostProvider.lambda$lookupActiveHost$3(SingleNodeHostProvider.java:101)
at org.springframework.data.elasticsearch.client.reactive.SingleNodeHostProvider$$Lambda$1993/0x0000000000000000.accept(Unknown Source)
at reactor.core.publisher.FluxHandle$HandleSubscriber.onNext(FluxHandle.java:103)
at reactor.core.publisher.FluxMap$MapConditionalSubscriber.onNext(FluxMap.java:220)
Codes
Bean
#Bean
public RestHighLevelClient elasticsearchClient() {
String hostAndPort = new HttpHost(getElasticsearchProperty().getConnectionProperty().getHosts(), Integer.parseInt(getElasticsearchProperty().getConnectionProperty().getPorts())).toHostString();
ClientConfiguration clientConfiguration = ClientConfiguration.builder()
.connectedTo(hostAndPort)
.build();
return RestClients.create(clientConfiguration).rest();
}
Configuration yml
filename: elasticsearch-local.yml
elasticsearch:
contents:
connectionProperty:
hosts: {remote-es-host}
ports: {remote-port}
connectionTimeout: 3000
socketTimeout: 5000
user: {user}
password: {password}
Project structure
Based on Gradle
ㄴ project
ㄴ project-api
ㄴ project-elasticsearch
project-api
Dependent on project-elasticsearch
NOW I'm trying to run test codes in THIS project.
project-elasticsearch
All configurations or utilities related with Elasticsearch
I've tried to run test codes in this project, and successfully connected to the remote ES cluster.
You didn't provide the configuration code of Elasticsearch, which according to your assumption should refer to the right host. Anyway, I believe that these links will explain everything you need to know how to configure it (I assume localhost is default since you don't configure it as needed).
Rest Elasticsearch config
High level Client config
I solve my problem to add below in the project-api.
spring:
autoconfigure:
exclude: >
org.springframework.boot.actuate.autoconfigure.elasticsearch.ElasticSearchReactiveHealthContributorAutoConfiguration,
org.springframework.boot.autoconfigure.data.elasticsearch.ReactiveElasticsearchRepositoriesAutoConfiguration,
org.springframework.boot.autoconfigure.data.elasticsearch.ReactiveElasticsearchRestClientAutoConfiguration
The problem is that, Spring's autoconfiguration tried to use ReactiveElasticsearchRestClient but there were no configurations for the reactive one. So, automatically it tried to connect to the localhost.
I currently have two microservices:
- service - port 8080, this microservice tries to fetch config from the other microservice.
- config - port 8888, this microservice is supposed to provide config.
For some reason my service is unable to fetch configuration from config microservice.
My config microservice should work because I can curl localhost:8888/service/default on my machine I receive:
{"name":"service","profiles":["default"],"label":null,"version":null,"state":null,"propertySources":[{"name":"classpath:/shared/service.yml","source":{"server.port":8080,"spring.security.user.password":"admin"}},{"name":"classpath:/shared/service.yaml","source":{"server.port":8080,"spring.security.user.password":"admin"}}]}
Error received (full)
service | 2019-06-06 21:31:06.721 INFO 1 --- [main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://config:8888
service | 2019-06-06 21:31:06.894 INFO 1 --- [main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://config:8888. Will be trying the next url if available
service | 2019-06-06 21:31:06.904 ERROR 1 --- [main] o.s.boot.SpringApplication : Application run failed
Docker-compose.yaml
version: '3.7'
services:
config:
container_name: config
build: ./config
ports:
- 8888:8888
service:
container_name: service
build: ./service
ports:
- 8080:8080
depends_on:
- config
Service Dockerfile:
FROM openjdk:8-jdk-alpine
ADD target/service.jar /app.jar
CMD [ "java", "-Xmx200m", "-jar", "/app.jar" ]
EXPOSE 8080
Service bootstrap.yaml
spring:
application:
name: service
cloud:
config:
uri: http://config:8888
fail-fast: true
service.yaml (has service configuration)
server:
port: 8080
spring:
security:
user:
password: admin # doesnt set since no connection
Config Dockerfile
FROM openjdk:8-jdk-alpine
ADD target/config.jar /app.jar
CMD [ "java", "-Xmx200m", "-jar", "/app.jar" ]
EXPOSE 8888
Config application.yaml
spring:
application:
name: config
profiles:
active: composite
cloud:
config:
server:
composite:
- type: native
search-locations: classpath:/shared
server:
port: 8888
shared/service.yaml (has service configuration)
server:
port: 8080
spring:
security:
user:
password: admin # doesnt set since no connection
Any ideas?
I found some similar issues, although they only had issues with their URI, mine is set correctly.
Microservice can not reach to Config Server on Docker Compose
Docker - SpringConfig - Connection refused to ConfigServer
When one service depends on another you have to make sure that the latter is fully started before connecting to it.
In your case, most probably, config is started but not ready (context started) at the time service is run. As #Ganesh Karewad and #asolanki pointed out, a solution is to implement a reconnection logic. Another solution is to make sure config is initialized and accepting connections before you run service.
You can achieve that with a script that waits until the config app is up. In alternative you could configure the config container with a health check command and after you start it, wait until it is marked as healthy. Then you can run the service container.
Similar issue discussed here and here
Hope that helps.
I try to starting my application(Spring Boot + Spring Cloud + Eureka + MongoDB) with using docker image, but i can't get connection to MongoDB.
Exception:
exception "com.mongodb.MongoSocketOpenException: Exception opening socket."
I starting my application with execute command: docker-compose up --build
Docker log:
com.mongodb. MongoSocket0penException: Exception opening socket at com.mongodb. connection. SocketStream.open(SocketStream.java: 63) ~|mongo-java-driver-3.2.2.jar!/:naj
at com. monsoob: connection. berettaberverwontortser/ersonito-kunnablearancerainitservertonitolnava:1203-dionso-java-driver*3?2.2.jarl/:nal
at : java. lang. Thread.run (Thread. java: 745) Lna:1.8.0_111]
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect (Native Method) ~ [na: 1.8.0_1111 at java.net.AbstractPlainSocketImp1.doConnect (AbstractplainSocketImpl.java:350) ~ [na: 1.8.0_111]
at java.net.AbstractPlainSocketImp1.connectToAddress(AbstractPlainSocketImp1.java:206)~[na:1.8.0_1111
at java.net .AbstractPlainSocketImp1.connect (AbstractPlain5ocket Imp],java:188) ~[na:1.8.0_111]
at java.net.SocksSocketImpl.connect (SocksSocketImpl.java:392) ~|na:1.8.0_111] java.net Socket. connect (Socket, java: 589) ~[na:1.8:0-111]
at com.mongodb.connection. SocketStreamHelper.initialize(SocketStreamHelper. java: 50) ~ [mongo-java-driver-3.2.2.ar!/:na] at com. mongodb. connection. SocketStream.open(SocketStream. java:58) ~ [mongo-java-driver-3.2.2.jar!/:na]
3 common frames omitted
application.yml:
# Spring properties
spring:
application:
name: car-service
data:
mongodb.host: localhost
mongodb.port: 32769
mongodb.uri: mongodb://localhost/test
mongo.repositories.enabled: true
# Discovery Server Access
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
# HTTP Server (Tomcat) Port
server:
port: 2220
error:
whitelabel:
enabled: false
docker-compose.yml:
eureka:
build: ./eureka-discovery-service
ports:
- "8761:8761"
mongodb:
image: mongo:3.0.4
ports:
- "32769:32769"
postgresql:
image: postgres:9.6.1
ports:
- "32770:32770"
gateway-service:
build: ./gateway-service
ports:
- "9090:9090"
links:
- eureka
environment:
SPRING_APPLICATION_NAME: gateway-service
SPRING_PROFILES_ACTIVE: enableEureka
EUREKA_INSTANCE_PREFER_IP_ADDRESS: "true"
EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://eureka:8761/eureka/
airplane-service:
build: ./airplane-service
ports:
- "2222:2222"
links:
- eureka
- postgresql
environment:
SPRING_APPLICATION_NAME: airplane-service
SPRING_PROFILES_ACTIVE: enableEureka
EUREKA_INSTANCE_PREFER_IP_ADDRESS: "true"
EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://eureka:8761/eureka/
SPRING_SLEUTH_ENABLED: "true"
SPRING_DATASOURCE_POSTGRESQL_URL: jdbc:postgresql://localhost:32770/postgres
car-service:
build: ./car-service
ports:
- "2220:2220"
links:
- eureka
- mongodb
environment:
SPRING_APPLICATION_NAME: car-service
SPRING_PROFILES_ACTIVE: enableEureka
EUREKA_INSTANCE_PREFER_IP_ADDRESS: "true"
EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://eureka:8761/eureka/
SPRING_SLEUTH_ENABLED: "true"
SPRING_DATA_MONGODB_URI: mongodb://localhost:32769/test
machine-service:
build: ./machine-service
ports:
- "2224:2224"
links:
- eureka
environment:
SPRING_APPLICATION_NAME: machine-service
SPRING_PROFILES_ACTIVE: enableEureka
EUREKA_INSTANCE_PREFER_IP_ADDRESS: "true"
EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://eureka:8761/eureka/
SPRING_SLEUTH_ENABLED: "true"
Why I have exception opening a socket? How to fix this problem?
You are setting mongodb host in property file as localhost. In a container localhost address itself, but your mongodb is not in that container(car-service) which car-service run in. While you are using docker compose, you can address a container with its name. In your case it is mongodb.
to clarify #barbakini's answer, to define it in applications.yaml use:
spring.data.mongodb.host: mongodb
Your mongoDB service is not UP ,
Check the status by following command
sudo service mongodb status
sudo service mongodb start
Hope it should work, there could be several reasons as well ,
like the configuration you defined in your application for mongodb service is incorrect such as port .
Try to add
network_mode: host
and remove
links: ....
for all services, that want to connect with mongo or eureka or postgresql, inside your docker-compose.yml.
By doing so you will connect to docker localhost.
I setup a elasticsearch container with the OFFICIAL REPO elasticsearch docker image. Then run it with
docker run -dP elasticsearch
Easy and worked. The ps info is
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
658b49ed9551 elasticsearch:latest "/docker-entrypoint. 2 seconds ago Up 1 seconds 0.0.0.0:32769->9200/tcp, 0.0.0.0:32768->9300/tcp suspicious_albattani
And I can access the server with http-client via port 32769->9200
baihetekiMacBook-Pro:0 baihe$ curl 10.211.55.100:32769
{
"status" : 200,
"name" : "Scorpia",
"cluster_name" : "elasticsearch",
"version" : {
"number" : "1.4.5",
"build_hash" : "2aaf797f2a571dcb779a3b61180afe8390ab61f9",
"build_timestamp" : "2015-04-27T08:06:06Z",
"build_snapshot" : false,
"lucene_version" : "4.10.4"
},
"tagline" : "You Know, for Search"
}
Now I need my JAVA-program to work with the dockerized elasticsearch. The java Node client can only connected to the elasticsearch through 32768->9300 (the cluster node talking port). So I config the transport client in my java like this
Settings settings = ImmutableSettings.settingsBuilder()
.put("client.transport.sniff", true)
.put("client.transport.ignore_cluster_name", true).build();
client = new TransportClient(settings);
((TransportClient) client)
.addTransportAddress(new InetSocketTransportAddress(
"10.211.55.100", 32768));
Then I get the following errors in the console:
Caused by: org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: []
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:305)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:200)
at org.elasticsearch.client.transport.support.InternalTransportIndicesAdminClient.execute(InternalTransportIndicesAdminClient.java:86)
at org.elasticsearch.client.support.AbstractIndicesAdminClient.exists(AbstractIndicesAdminClient.java:170)
at org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder.doExecute(IndicesExistsRequestBuilder.java:53)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)
at cct.bigdata.yellowbook.service.impl.ResourceServiceImpl.<init>(ResourceServiceImpl.java:49)
at cct.bigdata.yellowbook.config.YellowBookConfig.resourceService(YellowBookConfig.java:21)
at cct.bigdata.yellowbook.config.YellowBookConfig$$EnhancerBySpringCGLIB$$e7d2ff3e.CGLIB$resourceService$0(<generated>)
at cct.bigdata.yellowbook.config.YellowBookConfig$$EnhancerBySpringCGLIB$$e7d2ff3e$$FastClassBySpringCGLIB$$72e3e213.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:312)
at cct.bigdata.yellowbook.config.YellowBookConfig$$EnhancerBySpringCGLIB$$e7d2ff3e.resourceService(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:166)
... 31 common frames omitted
When I run the elasticsearch directly in the host. everything is all right.
I check all the dockerfile of elasticsearch on docker hub. It seems all of them simply do the followings:
EXPOSE 9200 9300
I wonder has anyone tried to do the similar things. Is the 9300 the normal TCP port or UDP port? Do I need to do some special thing to make it when running the container? Thanks!
If you set "client.transport.sniff" to false it should work.
If you still want to use sniffing follow next instructions:
https://github.com/olivere/elastic/wiki/Docker
Detailed discussion here: https://github.com/olivere/elastic/issues/57#issuecomment-88697714
This works for me (in docker-compose.yml).
version: "2"
services:
elasticsearch5:
image: docker.elastic.co/elasticsearch/elasticsearch:5.5.3
container_name: elasticsearch5
environment:
- cluster.name=elasticsearch5-cluster
- http.host=0.0.0.0
- network.publish_host=127.0.0.1
- transport.tcp.port=9700
- discovery.type=single-node
- xpack.security.enabled=false
ports:
- "9600:9200"
- "9700:9700"
Specifying network.publish_host and transport.tcp.port seems to do the trick. And sniff=true still works.