Running Elasticsearch

In this lesson, we'll set up Elasticsearch and Kibana using Docker Compose, allowing us to add powerful search capabilities to our Restaurant Review Platform.

Setting Up Docker Compose

Docker Compose helps us run multiple containers that work together.

Let's create a new file called docker-compose.yaml in the root of our project.

Copy the following configuration into your docker-compose.yaml:

version: '3.8' services: elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch:8.12.0 container_name: elasticsearch environment: - node.name=elasticsearch - cluster.name=es-docker-cluster - discovery.type=single-node - bootstrap.memory_lock=true - xpack.security.enabled=false - 'ES_JAVA_OPTS=-Xms512m -Xmx512m' ulimits: memlock: soft: -1 hard: -1 volumes: - elasticsearch-data:/usr/share/elasticsearch/data ports: - '9200:9200' networks: - elastic kibana: image: docker.elastic.co/kibana/kibana:8.12.0 container_name: kibana ports: - '5601:5601' environment: - ELASTICSEARCH_HOSTS=http://elasticsearch:9200 depends_on: - elasticsearch networks: - elastic volumes: elasticsearch-data: driver: local networks: elastic: driver: bridge

Starting the Services

To start Elasticsearch and Kibana, open your terminal in the project root directory and run:

docker-compose up -d

The -d flag runs the containers in the background.

Wait about a minute for both services to start completely.

Configuring Spring Boot

Now we need to tell our Spring Boot application where to find Elasticsearch.

Add the following line to your application.properties file:

spring.elasticsearch.uris=http://localhost:9200

Verifying the Setup

Let's verify that everything is working correctly:

  1. Open your web browser and navigate to http://localhost:9200

  2. You should see a JSON response with Elasticsearch cluster information.

  3. Visit http://localhost:5601 to access Kibana, which is a helpful tool for managing and visualizing your Elasticsearch data.

graph LR subgraph Docker Network: elastic ES[Elasticsearch<br/>:9200] KB[Kibana<br/>:5601] end APP[Spring Boot<br/>Application] APP -->|http://localhost:9200| ES KB -->|http://elasticsearch:9200| ES classDef container fill:#e1f5fe,stroke:#01579b classDef app fill:#e8f5e9,stroke:#1b5e20 class ES,KB container class APP app

Summary

  • Docker Compose configured to run Elasticsearch and Kibana locally
  • Elasticsearch runs on port 9200, Kibana on port 5601
  • Application configured to connect to Elasticsearch
  • Data persists through container restarts using Docker volumes
© 2026 Devtiro Ltd. All rights reserved