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 .
Enter fullscreen mode Exit fullscreen mode

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

// 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:
Enter fullscreen mode Exit fullscreen mode

In the directory where docker-compose is located

docker-compose  up
Enter fullscreen mode Exit fullscreen mode

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

Image description

Top comments (3)

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
 
vahidalvandi profile image
vahid alvandi

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

Kibana server is not ready yet.