Sunday, September 21, 2014

Docker Elastisearch

Simple Configuration


1) Create a directory for local data:

mkdir `pwd`/data-dir

2) Create an elasticsearch config inside of the local data dir:

vim data-dir/elasticsearch.yml

path:
  logs: /data/log 
  data: /data/data

3) Create a script as such:

CONTAINER_NAME="elasticsearch_server"
ELASTIC_DATA_DIR="`pwd`/data-dir"
HOST_PORT_1="9200"
HOST_PORT_2="9300"

if [ ! -d "${ELASTIC_DATA_DIR}" ]
then
    mkdir -p "${ELASTIC_DATA_DIR}"
fi

docker rm ${CONTAINER_NAME}
sudo docker run -it --name ${CONTAINER_NAME} --rm \
    -p ${HOST_PORT_1}:9200 \
    -p ${HOST_PORT_2}:9300 \
    -v ${ELASTIC_DATA_DIR}:/data \
    dockerfile/elasticsearch \
    /elasticsearch/bin/elasticsearch -Des.config=/data/elasticsearch.yml

No comments: