Linking Kibana and Elasticsearch with docker-compose

I read this docs about installing elasticsearch. And run the command

docker pull docker.elastic.co/elasticsearch/elasticsearch:7.0.0

And this on for kibana

docker pull docker.elastic.co/kibana/kibana:7.0.0

Then I create a docke-compose.yml file:

version: '3'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.0.0
    ports:
      - 9200:9200
  kibana:
    image: docker.elastic.co/kibana/kibana:7.0.0
    ports:
      - 5601:5601
    environment:
      ELASTICSEARCH_HOSTS: http://localhost:9200 

Then I do docker-compose up.

I'm not really familiar with docker compose but I tried to read the docs about it. But there's still no response in either of the port. But when I run the docker container for elasticsearch alone it works but not on kibana.

Can you try to modify the env. variable ELASTICSEARCH_HOSTS with http://elasticsearch:9200.
Or just remove the variable from the compose file, as by default, it's set with the proper value : https://www.elastic.co/guide/en/kibana/current/docker.html#docker-defaults.

Still the same. Here is the error elastic_elasticsearch_1 exited with code 78.

This works for me :

version: '3'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.0.0
    environment:
      - discovery.type=single-node
    ports:
      - 9200:9200
  kibana:
    image: docker.elastic.co/kibana/kibana:7.0.0
    ports:
      - 5601:5601
2 Likes

It works now. Thank you :+1:. How about the depends_on and networks? and what are the reasons why the previous didn't work?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.