You're reading for free via D's Friend Link. Become a member to access the best of Medium.

Member-only story

How to run a local Elasticsearch using Docker (in under 5 min)?

D
3 min readAug 7, 2024
Photo by Roberto Sorin on Unsplash

Check out this link if you would like to read this for free.

Elasticsearch is a document based database that boasts excellent search speeds. Let’s set it up. There are a few ingredients in order to use elasticsearch accordingly. These include

  • Networks
  • Services — Elastic and Kibana

A full guide on this subject matter is available from the official elasticsearch documentation.

Create a network

docker network create elastic

Create an elastic service

docker run --name es01 --net elastic -p 9200:9200 -it -m 1GB docker.elastic.co/elasticsearch/elasticsearch:8.14.3

Get password



━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ Elasticsearch security features have been automatically configured!
✅ Authentication is enabled and cluster connections are encrypted.

ℹ️ Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):
fY
=VNDEBfDe9Y=I_u+5J

ℹ️ HTTP CA certificate SHA-256 fingerprint:
9f9219ad6783c82b67f5d680344ec001b3f58fe653219c77801bf08103045313

ℹ️ Configure Kibana to use this cluster:
• Run Kibana and click the configuration link in the terminal when Kibana starts.
Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes):
eyJ2ZXIiOiI4LjE0LjAiLCJhZHIiOlsiMTcyLjE4LjAuMjo5MjAwIl0sImZnciI6IjlmOTIxOWFkNjc4M2M4MmI2N2Y1ZDY4MDM0NGVjMDAxYjNmNThmZTY1MzIxOWM3NzgwMWJmMDgxMDMwNDUzMTMiLCJrZXkiOiJIeFowTFpFQjVRWkJjazcxTUozSTpZTnU3MkhvY1NNNnNDVlV5NFdtX21nIn0
=

The password is printed when the elastic container is run. Take note of the enrollment token as well. We will need this to set up kibana.

Create a Kibana service

docker run --name kib01 --net elastic -p 5601:5601 docker.elastic.co/kibana/kibana:8.14.3

Once the above command is run, the console logs will show a url to go to. In my case I had to replace 0.0.0.0 with localhost in order to get it working. Not sure what’s up with that.

url signup for kibana

Once it works, you wil be greeted with the page below.

paste the enrollment token
Log in using the username and password from before

Run wild!

Dev Console

There you have it, your own console to run all the elasticsearch commands as you wish.

Tear Down

Remove kibana

docker container stop kib01
docker container rm kib01

Remove elasticsearch

docker container stop es01
docker container rm es01

Remove the volume

docker volume rm elastic
D
D

Written by D

An aspiring Robotics Researcher. I am currently in my 4th year of undergraduate studies. I am working on optimising the ROS navigation packages. Follow 4 more!

No responses yet

Write a response