/ ELASTICSEARCHDOCKER

Install Elasticsearch With Docker

What Is Elasticsearch

Elasticsearch is an open source search engine highly scalable. It allows you to keep and analyse a great volume of information practically in real time. Elasticsearch works with JSON documents files. Using an internal structure, it can parse your data in almost real time to search for the information you need. It is very useful when working with big data.

What is Docker?

Docker is the world’s leading software container platform. Developers use Docker to eliminate “works on my machine” problems when collaborating on code with co-workers. Operators use Docker to run and manage apps side-by-side in isolated containers to get better compute density.

Enterprises use Docker to build agile software delivery pipelines to ship new features faster, more securely Elasticsearch is also available as Docker images. The images use centos:7 as the base image. A list of all published Docker images and tags is available at www.docker.elastic.co.

Pulling the image

docker pull docker.elastic.co/elasticsearch/elasticsearch:6.7.2
  1. Elasticsearch can be quickly started for development or testing use with the following command:
docker run -p 9200:9200 -p 9300:9300 --name elasticsearch -e
"discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.6.1
  1. Running Elasticsearch using Docker Compose: To bring up the cluster, use the docker-compose.yml and just type: docker-compose up The node elasticsearch listens on localhost:9200 while elasticsearch2 talks to elasticsearch over a Docker network. docker-compose.yml
version: '2.2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.7.2
container_name: elasticsearch
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata1:/usr/share/elasticsearch/data
ports:
- 9200:9200
networks:
- esnet
elasticsearch2:
image: docker.elastic.co/elasticsearch/elasticsearch:6.7.2
container_name: elasticsearch2
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=elasticsearch"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata2:/usr/share/elasticsearch/data
networks:
- esnet
volumes:
esdata1:
driver: local
esdata2:
driver: local
networks:
esnet:

To stop the cluster, type docker-compose down. Data volumes will persist, so it’s possible to start the cluster again with the same data using docker-compose up. To destroy the cluster and the data volumes, just type docker-compose down -v.

Read More