Installing and running a local environment with Docker Compose

We will run a single-node Elasticsearch + Kibana stack locally using Docker Compose. Security is disabled to keep the local setup simple — never disable security in production.

Prerequisites

docker-compose.yml

Create a file named docker-compose.yml in a new folder (e.g. ~/es-training/):

version: "3.8"

services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:9.4.2
    container_name: es01
    environment:
      - discovery.type=single-node
      - xpack.security.enabled=false
      - ES_JAVA_OPTS=-Xms1g -Xmx1g
      - cluster.routing.allocation.disk.threshold_enabled=false
    ulimits:
      memlock:
        soft: -1
        hard: -1
    ports:
      - "9200:9200"
    volumes:
      - es-data:/usr/share/elasticsearch/data

  kibana:
    image: docker.elastic.co/kibana/kibana:9.4.2
    container_name: kibana01
    environment:
      - ELASTICSEARCH_HOSTS=http://elasticsearch:9200
    ports:
      - "5601:5601"
    depends_on:
      - elasticsearch

volumes:
  es-data:
    driver: local

Note on versions: We use 9.4.2 above. Swap in the latest 8.x or 9.x tag — just make sure ES and Kibana versions match exactly. Check https://www.docker.elastic.co for available tags.

RAM: The ES_JAVA_OPTS=-Xms1g -Xmx1g setting gives the JVM 1 GB heap. For small datasets that is fine. If you see out-of-memory errors, increase to -Xms2g -Xmx2g and make sure Docker has enough RAM allocated.

Start the stack

docker compose up -d

Elasticsearch takes 20–40 seconds to start. Check the logs if needed:

docker compose logs -f elasticsearch

Look for the line: started or recovered [0] indices.

Verify Elasticsearch is running

curl -s http://localhost:9200

You should see a JSON response like:

{
  "name" : "es01",
  "cluster_name" : "docker-cluster",
  "version" : {
    "number" : "9.4.2",
    ...
  },
  "tagline" : "You Know, for Search"
}

Open Kibana

Open your browser and navigate to: http://localhost:5601.

Kibana may take a minute to start. Once loaded, go to:

Hamburger menu → Management → Dev Tools

This is where we will run all our API calls throughout the course.

Alternative: Elastic Cloud If you prefer not to run Docker locally, Elastic Cloud (https://cloud.elastic.co) offers a free trial with a hosted cluster. Everything in this course works identically against a cloud cluster — just replace localhost:9200 with your cloud endpoint and add authentication headers.

Stop the stack (when done)

docker compose down

Add -v to also delete the stored data volume:

docker compose down -v