DEV Community

Birol AYDIN
Birol AYDIN

Posted on

Installing Elasticsearch and Kibana with Docker compose

  • Briefly installing Elasticsearch and Kibana with Docker compose.
  • You can work with Elasticsearch and Kibana running in docker environment by following the steps below. ```

//Windows powershell
mkdir Elasticsearch8.7.1


Enter fullscreen mode Exit fullscreen mode

cd Elasticsearch8.7.1


Enter fullscreen mode Exit fullscreen mode

New-Item -Path "docker-compose.yml"


Enter fullscreen mode Exit fullscreen mode

code .

**NOTE: Before running docker-compose, make sure Docker is installed and running on your computer :)
**


Enter fullscreen mode Exit fullscreen mode

// docker-compose.yml
version: '3'
services:
elasticsearch:
container_name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:8.7.1
# 8.x
environment: ['CLI_JAVA_OPTS=-Xms2g -Xmx2g','bootstrap.memory_lock=true','discovery.type=single-node','xpack.security.enabled=false', 'xpack.security.enrollment.enabled=false']
ports:
- 9200:9200
networks:
- elastic
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
deploy:

resources:
limits:
cpus: '2.0'
reservations:
cpus: '1.0'

kibana:
image: docker.elastic.co/kibana/kibana:8.7.1
container_name: kibana
environment:
XPACK_ENCRYPTEDSAVEDOBJECTS_ENCRYPTIONKEY: d1a66dfd-c4d3-4a0a-8290-2abcb83ab3aa
ports:
- 5601:5601
networks:
- elastic
deploy:

resources:
limits:
cpus: '2.0'
reservations:
cpus: '1.0'

networks:
elastic:

In the directory where docker-compose is located

Enter fullscreen mode Exit fullscreen mode

docker-compose up

You can see the containers working from Docker Desktop application. Click on the links Elasticsearch and kibana to see that both are ready to use.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/30d57qx41lbra87y62g0.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eflz1jzp9woku39ah84z.png)
Enter fullscreen mode Exit fullscreen mode

Top comments (5)

Collapse
 
jerasokcm profile image
jerasokcm • Edited

Good starting point. Thanks.

Two questions:

1) Is the data persistent with this setup?
2) Is the Kibana instance ready to access the Elasticsearch data or there is the need to do additional configuration?

Collapse
 
sickprodigy profile image
SickProdigy • Edited

Having troubles myself getting this working. In the docker compose provided above there's this key that seems not safe to reuse over and over.
'XPACK_ENCRYPTEDSAVEDOBJECTS_ENCRYPTIONKEY: d1a66dfd-c4d3-4a0a-8290-2abcb83ab3aa'

To answer your questions though,
1> No, there are no bind mounts for :/usr/share/elasticsearch/data or
/usr/share/kibana/config (i'm not sure if needed for kibana really, but I know for data elasticsearch, bind mount is needed to stay persistent and not delete later.)
2> I'm not sure how but kibana can access elasticsearch by generated key. Not really sure how it get's the key. but it seems to get it in my instance and says (redacted) where it should be in logs.

With all that said, I'm still having issues with kibana being able to access integrations to install.

Collapse
 
birolaydin profile image
Birol AYDIN

1 ) Data is permanent.

2 ) No additional configuration is required, they are directly connected to each other.

Collapse
 
vahidalvandi profile image
vahid alvandi

but after http://localhost:5601/ return error

Kibana server is not ready yet.

Collapse
 
birolaydin profile image
Birol AYDIN

It should work without errors