Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose.yml for elasticsearch 7.0.1 and kibana 7.0.1

I am using Docker Desktop with linux containers on Windows 10 and would like to launch the latest versions of the elasticsearch and kibana containers over a docker compose file.

Everything works fine when using some older version like 6.2.4.

This is the working docker-compose.yml file for 6.2.4.

version: '3.1'

services:

  elasticsearch:
   image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4
   container_name: elasticsearch
   ports:
    - "9200:9200"
   volumes:
    - elasticsearch-data:/usr/share/elasticsearch/data
   networks:
    - docker-network

  kibana:
   image: docker.elastic.co/kibana/kibana:6.2.4
   container_name: kibana
   ports:
    - "5601:5601"
   depends_on:
    - elasticsearch
   networks:
    - docker-network

networks:
  docker-network:
    driver: bridge

volumes:
  elasticsearch-data:

I deleted all installed docker containers and adapted the docker-compose.yml file by changing 6.2.4 to 7.0.1. By starting the new compose file everything looks fine, both the elasticsearch and kibana containers are started. But after a couple of seconds the elasticsearch container exits (the kibana container is running further). I restarted everything, attached a terminal to the elasticsearch container and saw the following error message:

...
ERROR: [1] bootstrap checks failed
[1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
...

What must be changed in the docker-compose.yml file to get elasticsearch 7.0.1 working?

like image 447
RickyTad Avatar asked May 02 '19 16:05

RickyTad


People also ask

How to Mount docker-compose yml file in Elasticsearch data directory?

Navigate to the directory where you have created your docker-compose.yml file and create a subdirectory data. Then inside the data directory create another directory elasticsearch. We will be mounting this directory to the data directory of elasticsearch container. In your docker-compose.yml file there are these lines:

Do I need to re-pull Elasticsearch and Kibana before docker-compose?

You might need to re-pull them before running docker-compose, like docker pull elasticsearch and docker pull kibana .

Is it possible to run kibana and Elasticsearch on the same network?

Don't forget to use one of the documented methods to set Kibana configuration - ELASTICSEARCH_URL is required to be set! I have a docker compose file that creates two elasticsearch nodes and a kibana instance all running on the same bridged network. It is possible.

Is it possible to install Kibana plugin from command line?

So when you override command section you must remember to keep existing behavior which is set by image author. So in you case you can actually install kibana plugin this way but you must also add Kibana start at the end of the command by using e.g. && to run process after plugin installation.


1 Answers

Making a few changes worked for me -

  • Add cluster.initial_master_nodes to the elasticsearch service in compose -

    environment:
      - cluster.initial_master_nodes=elasticsearch
    
  • vm.max_map_count on the linux box kernel setting needs to be set to at least 262144 -

    $ sudo sysctl -w vm.max_map_count=262144
    

For development mode, you can use below settings as well -

    environment:
      - discovery.type=single-node

Working compose file for me -

version: '2.2'
services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.0.1
    container_name: es01
    environment:
      - cluster.initial_master_nodes=es01
    ulimits:
      memlock:
        soft: -1
        hard: -1
    ports:
      - 9200

For production mode, you must consider having multiple ES nodes/containers as suggested in the official documentation

https://www.elastic.co/guide/en/elasticsearch/reference/7.0/docker.html#docker-cli-run-prod-mode

like image 107
vivekyad4v Avatar answered Nov 15 '22 21:11

vivekyad4v