Step 1, Increase the lmit of virtual memory of your linux server
Even we are using docker, but docker images are still referring the global setting from their parent machine.
sudo sysctl -w vm.max_map_count=262144
sudo echo 'vm.max_map_count=262144' >> /etc/sysctl.conf
Step 2, pull the ES image from dockhub
docker pull elasticsearch:7.6.2
Step 3,run the ES image
please note that we expose 2 ports , 9200 and 9300.
after ES 7, we could use 9200 as the REST api and internal api.
but we could still open port 9300… no bad.
if your server has more then 1G memory , the xms xms parameter is not needed
docker run --name es_server -d -p 9200:9200 -p 9300:9300 -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -e "discovery.type=single-node" elasticsearch:7.6.2
Step 4,check the container logs
docker logs es_server | grep -i start
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
{"type": "server", "timestamp": "2022-08-30T17:33:40,497Z", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "docker-cluster", "node.name": "5971f0e6fc81", "message": "starting ..." }
{"type": "server", "timestamp": "2022-08-30T17:33:41,996Z", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "docker-cluster", "node.name": "5971f0e6fc81", "message": "started", "cluster.uuid": "lC-D1qCATgKPyQJ93lZFmA", "node.id": "elHGQazMQyWeIPy8KutxyQ" }
if you see the logs of started, then fine.
Step 5,test it from browser or curl command
curl http://localhost:9200
{
"name" : "5971f0e6fc81",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "lC-D1qCATgKPyQJ93lZFmA",
"version" : {
"number" : "7.6.2",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "ef48eb35cf30adf4db14086e8aabd07ef6fb113f",
"build_date" : "2020-03-26T06:34:37.794943Z",
"build_snapshot" : false,
"lucene_version" : "8.4.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}