Deploy Elastic Search With Docker
System Requirements
- 2+ GB RAM
Related Posts
Steps
Run the following command to deploy a basic elastic search server.
docker run \
-p 9200:9200 \
-p 9300:9300 \
-v ./elastic-search-data:/usr/share/elasticsearch/data \
-e "discovery.type=single-node" \
elasticsearch:7.9.0
If you want to use docker-compose, then create a docker-compose.yml
file with the following content
version: "3"
services:
elasticsearch:
container_name: elasticsearch
image: elasticsearch:7.9.0
restart: always
ports:
- 9200:9200
- 9300:9300
volumes:
- elastic-search-data:/usr/share/elasticsearch/data
environment:
discovery.type: single-node
volumes:
elastic-search-data:
driver: local
... then run
docker-compose up
Testing
Elasitc Search is just a RESTful JSON API so you can perform GET
requests just by using your browser. E.g. go to your server's hostname or ip address with port 9200 in your URL. e.g.
http://elastic-search.mydomain.com:9200
Or you can send a cURL request from the CLI like so:
curl $HOSTNAME_OR_IP:9200
You should get a message similar to:
{
"name" : "7b61c1d190c2",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "Nf1r4mXbSZmmM8JD0xPu0A",
"version" : {
"number" : "7.9.0",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "a479a2a7fce0389512d6a9361301708b92dff667",
"build_date" : "2020-08-11T21:36:48.204330Z",
"build_snapshot" : false,
"lucene_version" : "8.6.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
Security
With this setup, your elastic search server is open to the world for anyone to post logs or retrieve information from, so I recommend you put it behind a firewall of some sort.
Alternatively, implement user authentication. You may find it quickest to implement "native" authentication.
References
First published: 31st July 2020