Home ElasticSearch and Kibana setup with docker
Post
Cancel

ElasticSearch and Kibana setup with docker

ElasticSearch is a full text search engine and Kibana is a free and open user interface that lets you visualize your Elasticsearch data and navigate the Elastic Stack.

In this post we will see a summary of how we can configure both tools using docker and access them from the browser

Docker setup

We will use docker-compose here to setup both tools, but you can also use docker cli to acheive it.

create a docker-compose.yml file or I like to call it services.yml file where we will setup all the configuration options for both services

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
version: '3.7'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.2.2
    container_name: elasticsearch
    restart: always
    environment:
      - xpack.security.enabled=false
      - discovery.type=single-node
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    cap_add:
      - IPC_LOCK
    volumes:
      - elasticsearch-data:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
      - 9300:9300
  kibana:
    container_name: kibana_622
    image: docker.elastic.co/kibana/kibana:6.2.2
    restart: always
    environment:
      - ELASTICSEARCH_HOSTS=http://elasticsearch:9200
    ports:
      - 5601:5601
    depends_on:
      - elasticsearch

volumes:
  elasticsearch-data:
    driver: local

how to run it

1
docker-compose -f <filename.yml> up -d

And then visit http://localhost:5601 to see kibana dashbaord. Default password is elastic

  • -f option allow us to provide file name if file is different than docker-compose.yml.
  • -d option will run containers in deamon

How to clean restart these docker instance

IMPORTANT NOTE: below command will kill all processes and remove them. It will also remove all of the volume, so you will loose previous data

1
2
3
4
docker-compose down
docker rm -f $(docker ps -a -q)
docker volume rm $(docker volume ls -q)
docker-compose -f services.yml up -d

How to fix test environment to use elastic search using chewy

Create config/initializers/chewy.yml file and add following

1
Chewy.settings = { host: 'localhost:9200' }

Or change the port where your elastic search is running, if you had made any changes on above services.yml file

This post is licensed under CC BY 4.0 by the author.