elasticsearch

Start from docker

  • Pulling the image
1
docker pull docker.elastic.co/elasticsearch/elasticsearch:6.4.2
  • Run in Development Mode
1
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.4.2
  • Dockerfile

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    FROM docker.elastic.co/elasticsearch/elasticsearch:6.4.2

    ENV ES_HOME /opt/elasticsearch
    WORKDIR ${ES_HOME}

    ENV discovery.type single-node
    ENV ES_HEAP_SIZE 512m
    ENV MAX_OPEN_FILES=65535
    ENV MAX_LOCKED_MEMORY=unlimited

    #VOLUME ${ES_HOME}/es-data

    EXPOSE 9200 9300
  • Run

  • 1
    docker-compose up -d --build elasticsearch
  • Test

  • 1
    2
    3
    curl -XPUT http://localhost:9200/test/_doc/1 -H 'Content-Type: application/json' -d '{"id": 1, "name": "tom" }'

    {"_index":"test","_type":"_doc","_id":"1","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":0,"_primary_term":1}
    1
    2
    3
    curl http://localhost:9200/test/_doc/1

    {"_index":"test","_type":"_doc","_id":"1","_version":1,"found":true,"_source":{"id": 1, "name": "tom" }}