Setup Elasticsearch & Kibana via Docker
Tags: Elasticsearch, Docker Compose, Docker, Data Science, Kibana

First things first, you must have Docker and Docker compose setup and installed on your machine. If you don’t have it installed already, follow this link to set it up on your machine.

For this tutorial, we will be making use of the docker-compose command to spin up our own containers running Elasticsearch and Kibana.

Go ahead and create a docker-compse.yml file and paste the code below,

version: '3'

services:

elasticsearch:

image: elasticsearch:7.8.1

ports:

- 9200:9200

environment:

discovery.type: 'single-node'

xpack.security.enabled: 'true'

ELASTIC_PASSWORD: '<your_password>'

kibana:

image: kibana:7.8.1

volumes:

- ./kibana.yml:/usr/share/kibana/config/kibana.yml

ports:

- 5601:5601

This Docker compose recipe spins up 2 Docker containers on your machine. One container running Elasticsearch 7.8.1 and the other running Kibana 7.8.1. It maps Elasticsearch API to port 9200 and Kibana to port 5601 on your machine. You can check the official Docker images for all available configuration options for Elasticsearch and Kibana. For this tutorial, we will be enabling security on Elasticsearch (duh!) and configuring a password (default username is “elastic”).

The recipe also mounts the kibana.yml to the Kibana config directory, you will need to make a few changes to the file to make sure Kibana connects correctly to your container running Elasticsearch.

# To allow connections from remote users, set this parameter to a non-loopback address. server.host: "0.0.0.0" # The URLs of the Elasticsearch instances to use for all your queries. elasticsearch.hosts: [" http://elasticsearch:9200 "] # If your Elasticsearch is protected with basic authentication, these settings provide

# the username and password that the Kibana server uses to perform maintenance on the Kibana

# index at startup. Your Kibana users still need to authenticate with Elasticsearch, which

# is proxied through the Kibana server. elasticsearch.username: "elastic"

elasticsearch.password: "<your_password>"

After both yml files are ready, open up a terminal and navigate to your directory and execute the below command,

docker-compose up

Docker will download the images for Elasticsearch and Kibana and setup your containers. After successful completion you will be able to see your containers running,

Elasticsearch and Kibana containers running

Head on over to http://localhost:9200/ to verify that Elasticsearch is now running (key in your username and password, default username is “elastic”), you should see a response like below,

{

"name": "localhost",

"cluster_name": "elasticsearch",

"cluster_uuid": "DoZwos0YR26WsHSZYO4O2A",

"version": {

"number": "7.8.1",

"build_flavor": "default",

"build_type": "tar",

"build_hash": "508c38a",

"build_date": "2019-06-20T15:54:18.811730Z",

"build_snapshot": false,

"lucene_version": "8.5.1",

"minimum_wire_compatibility_version": "6.8.0",

"minimum_index_compatibility_version": "6.0.0-beta1"

},

"tagline": "You Know, for Search"

}

Follow this link to check out the documentation for the Elasticsearch Search API.

To verify that Kibana is successfully up and running on your machine, head on over to http://localhost:5601/ and key in your username and password,

Verify Kibana is running, you should be met with a login screen

After logging in you can use the full potential of Kibana,

Kibana Home screen

Thanks for reading, that’s all folks!