I am using official elastic search docker container image in docker compose in linux (ubunut 24.04 lts) . I am working with different project with having elastic search container image in each project so i can’t use the default host port. Like a default port binding host to container is 9200:9200
and I want to map this like 10200:9200
. But this is not working.
I am try to connecting through js client of elastic search but it give
error called connection refused
How can i solve this ?
My docker-compose.yaml
file is below
services:
blog-elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.15.0
container_name: b-elasticsearch
environment:
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ports:
- "10200:9200"
- "10300:9300"
volumes:
- es_data:/usr/share/elasticsearch/data
Update i got the answer
So basically I got the answer . After go through lot of pain , i got the reason why i was getting error .
when I was building the elastic search container image through docker compose , after a very very short time i did the test to connect to the container . since it was not ready for getting the request from outside , the container was refusing to connect . So I got the error. But after a few second container was being connected from outside world.
2