Dear community,
I'm new to elastic & i'm trying to cloud-ize my application via docker then kubernetes.
I've built the same Springboot app as:
To test this app:
1. Pull docker image
a. docker pull docker.elastic.co/elasticsearch/elasticsearch:6.8.2
b. docker pull docker.elastic.co/elasticsearch/kibana:6.8.2
2. Run image on docker
a. docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.8.2
b. docker run --link :elasticsearch -p 5601:5601 docker.elastic.co/kibana/kibana:6.8.2
3. both locahost:9200 & 5601 are ping-able
4. mvn package app into jar & run it
java -jar elastic-client-0.0.1-LOCAL.jar
4.5. application.properties
elasticsearch.host=http://localhost:9200
5. CRUD successful via curl or "postman" (a restful client) works too
6. build docker image successfully then push to private repo by:
docker build -t hironwayj/elastic-client-local .
docker push hironwayj/elastic-client-local
here's my dockerfile:
FROM maven:3.5-jdk-8-alpine as builder
WORKDIR /app
COPY pom.xml .
COPY src ./src
RUN mvn package -DskipTests
FROM openjdk:8-jre-alpine
COPY --from=builder /app/target/elastic-client-0.0.1-LOCAL.jar /elastic-client-local.jar
CMD ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/elastic-client-local.jar"]
7. run docker image
docker run -p 8080:8080 hironwayj/elastic-client-local
8. Failed when CRUD with connection refused
java.net.ConnectException: Connection refused
at org.elasticsearch.client.RestClient$SyncResponseListener.get(RestClient.java:943) ~[elasticsearch-rest-client-6.4.3.jar!/:6.8.2]
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:227) ~[elasticsearch-rest-client-6.4.3.jar!/:6.8.2]
at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1764) ~[elasticsearch-rest-high-level-client-6.8.2.jar!/:6.8.2]
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1734) ~[elasticsearch-rest-high-level-client-6.8.2.jar!/:6.8.2]
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1696) ~[elasticsearch-rest-high-level-client-6.8.2.jar!/:6.8.2]
at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:1092) ~[elasticsearch-rest-high-level-client-6.8.2.jar!/:6.8.2]
at com.hackthon.tk.elasticclient.service.ProfileService.findAllProfile(ProfileService.java:70) ~[classes!/:0.0.1-LOCAL]
at com.hackthon.tk.elasticclient.controller.ProfileController.findAll(ProfileController.java:40) ~[classes!/:0.0.1-LOCAL]
Did i configure somewhere wrong? Why is java -jar runnable while failed in docker image?
Thank you so much!