Setup and test elasticsearch quickly
If you are using elasticsearch for the first time, then you might be thinking on how to setup elasticsearch quickly. In this post, we will learn how to setup elasticsearch
and kibana
using docker.
Make sure docker is already installed on your system, if not follow this link to install docker.
Quickly setup and test elasticsearch
Quickly run single node cluster using docker.
Port 9200
is for Rest API and 9300
is for other node communication.
docker run --name myelastic -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.8.1
Test if elasticsearch
is running using below curl command, it should successfully return node details.
curl -X GET "localhost:9200/_cat/nodes?v&pretty"
Quickly setup kibana
Kibana
is open source data visualization tool for elasticsearch but it also provide query builder interface through which you can run various query against elasticsearch. Its Query builder interface provide auto completion.
docker run --link myelastic:elasticsearch -p 5601:5601 docker.elastic.co/kibana/kibana:7.8.1
After successfull start, open http://localhost:5601/ to view kibana user interface.
Elasticsearch and Kiban with docker-compose
If you want to start multiple service with docker then it better to use docker-compose instead of docker command line.
Paste below code in docker-compose.yaml
file and run docker-compose up
to start elasticsearch and kibana.
version: "3.8"
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.8.1
container_name: elasticsearch-dc
ports:
- "9200:9200"
- "9300:9300"
environment:
- discovery.type=single-node
kibana:
image: docker.elastic.co/kibana/kibana:7.8.1
container_name: kibana-dc
ports:
- "5601:5601"
links:
- "elasticsearch:elasticsearch"
depends_on:
- elasticsearch