docker-compose.yml for elasticsearch 7.0.1 and kibana 7.0.1

RickyTad picture RickyTad · May 2, 2019 · Viewed 11.8k times · Source

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?

Answer

vivekyad4v picture vivekyad4v · May 2, 2019

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