Run elasticsearch on a single node through Docker

Docker has made life really simple, you can run anything locally without worrying about compatibility issues.

The same goes for the ElasticSearch, We can run it easily through docker.

Get the docker image downloaded of the preferred version of elastic search and run it through docker-compose.yml.

Though we can run an elastic search on multiple nodes to distribute data with master-servant architecture, but there are many cases where you just want to run one node and that can be done through a single configuration in docker-compose.yml.

discovery.type=single-node is an elastic search configuration that runs the ES on a single node. We can just add this in the environment configuration.

version: "3.7"
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.10.2
    container_name: elasticsearch
    environment:
      - xpack.security.enabled=false
      - discovery.type=single-node
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    cap_add:
      - IPC_LOCK
    volumes:
      - elasticsearch-data:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
      - 9300:9300

volumes:
  elasticsearch-data:
    driver: local