0
votes

I have a docker-compose.yaml file with elasticsearch and kibana defined.

When I run docker-compose, I will be able to access kibana with the url http://localhost:8181 with everything running as exepcted. However, my issue is that I do not want to use elasticsearch port 9200 in kibana, I want to use another port (ex. 9201)

How can I make elasticsearch connect in kibana while using a port different than 9200?

I have tried adding the following below but I get an error "Unable to connect to Elasticsearch at http://elasticsearch:9201."

elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.3
    environment:
        discovery.type: single-node
    ports:
        -"9201:9200"

kibana:
    depends_on:
        - elasticsearch
    image: docker.elastic.co/kibana/kibana-oss:6.2.3
    environment:
        SERVER_NAME: "s_name"
        ELASTICSEARCH_URL: http://elasticsearch:9201
    ports:
        - "8181:5601"

The below works fine with port 9200

elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.3
    environment:
      discovery.type: single-node

kibana:
    depends_on:
      - elasticsearch
    image: docker.elastic.co/kibana/kibana-oss:6.2.3
    environment:
      SERVER_NAME: "s_name"
      ELASTICSEARCH_URL: http://elasticsearch:9200
    ports:
      - "8181:5601"
1
Hi, could you please tell us what was the final solution? I am facing the same issue hereDoston
thanks, I got it workingDoston

1 Answers

0
votes

ELASTICSEARCH_URL: http://elasticsearch:9201

Set this to ELASTICSEARCH_URL: http://elasticsearch:9200 instead.

"9201:9200" maps from container port to host port. That is, it exposes 9201 on your host's network interfaces, and forwards it to port 9200 in the container.

Your Kibana service however, was trying to connect to 9201 of elasticsearch - a different container on a different network w/ a different IP address, not 127.0.0.1, and in that network, the container is running a process on port 9200.

EDIT: reading again, you can configure the port Configure port number of ElasticSearch. Try setting http.port in the environment (based on https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-configuration-methods):

elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.3 environment: discovery.type: single-node http.port: 9201-9301 ports: -"9201:9201"