I am creating an elasticsearch image and want to run the container on some remote machine.
Suppose the machine hostname is "abc.com"
, so I am accessing the URL as "abc.com:9200"
to access elasticsearch. After testing successfully, this container will be deployed to Kubernetes.
But to access elasticsearch (for filebeat, kibana and logstash) I need some static hostname so that while accessing it from different applications will be easy.
I am trying to make the hostname "elasticsearch"
and want it to access as "http://elasticsearch:9200"
.
PS: I am new to Docker, and want to clear my doubts by asking silly questions
I have tried adding "--hostname" and "--add-host", both didnt worked.
docker run -d --name=elasticsearch \ --network=elk \ -p=9200:9200 -p 9300:9300 \ --hostname "elasticsearch" \ elasticsearch:7.17.6
Expecting to get the response by accessing "http://elsaticsearch:9200"